Yes, perfectly fine. You can also put variables in there if you need. If you declare them static, you’ll be able to access them globally the via class name without needing to instantiate any objects.
This pretty much gets you the same global storage functionality as using an autoload, but you don’t need to drag a dangling node along.
I actually prefer using this approach over autoloads for global data storage.
I thought it was possible to make Autoloads for Nodes and RefCounted scripts last time I used it. I don’t think Autoloads need to always create dangling nodes.
Nice thing about Autoloads is everyone knows there in order to look there in order to find the things that are intentionally global. But both class_name and Autoloads might be seen as cluttering the global name space.
I like to avoid globals of both kinds as much as possible. If not possible I prefer Autoloads for global variables or helper functions. I try to reserve class_name for everything that is part of the program’s main domain. For anything else scripts can be locally loaded by file name in order to make them accessible from other scripts with load() (or preload).
Autoloads are always nodes parented to scene tree’s root. That’s the mechanism. You can’t setup a non-node class as an autoload because its instance cannot be added to the scene tree. The engine will complain and disobey.
In both cases, whether using an autoload or a static class, you’ll expend exactly one name in the global namespace. So in that respect it makes no difference.
Minimizing the usage of global variables is always good, of course.
Since I remembered Godot not complaining last time I added a script as a global I now tried it out.
In fact I can add a script as a global, but when I run it I get an error. Maybe something to be aware of.
The engine will in fact print some errors in the output immediately after you set up an autoload in the project settings.
Btw, you can see all your autoloaded nodes at runtime if you look at the remote scene tree. So autoloads by design always need to be present in the tree, and that wouldn’t be possible if the class is not a node class.