0 votes

I register class name with class_name keyword

extends Object
class_name MyClass

And than inside other script I instantiate it like that

var obj = MyClass.new()

Is it differs from that methods?

var MyClass = preload("MyClass.gd")
var obj = MyClass.new()


var MyClass = load("MyClass.gd")
var obj = MyClass.new()

If I instantiate object using registered class_name, will be script loaded during runtime or during compilation time?

in Engine by (246 points)

1 Answer

+1 vote

you can read about it here:


  • Named scripts are registered globaly on startup.
  • Preloaded scripts are loaded into a var or const in a class on compile time. They are not globaly accessable.
  • Loaded scripts are loaded on runtime into a class variable. They are not globaly accessable.
by (3,132 points)

So, will it be loaded before runtime?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.