Can I lazyload atom packages?


Atom startup is slow.

Some reason is Package Loading and Package Activation time is too long.

Please help.


No, you as a user can’t do that. Packages do have some kind of control themselves, though. If a package specifies commands in the activationCommands entry in its package.json, instead of being activated at Atom startup, the package will be activated when one of those commands is called for the first time.


I have saved 60% time to start atom. :grinning:



Packages do have some kind of control themselves, though

Not so much, depending on what the package does and needs in Atom.
One issue I faced both in Pigments and more recently in Tablr is when you have a model that is displayed as a pane item and should be serialized along with the text editors. You’ll specify the deserializer to use in the output of the serialize method of the model. But as the workspace deserialization will take place before the activation of your package, you must register the serializer as soon as your package’s main file is loaded, meaning you can’t lazy load anything that need to be deserialized. And as you will also want to display your model in the pane as soon as its items are restored (because the workspace will attempt to get a view for it as soon as it gets deserialized) you also need to register the corresponding views. In Tablr it forces me to do this:

All that to say that if you want to speed up your package startup time by using serialization you may end up slowing it instead.


Hmm, that’s a bummer… Is there no way to defer deserialization, for example by keeping a reference to the serialized state until package activation?


Not when you let the workspace handles the serialization (by providing a serialize method on your pane item). And in the case you don’t provide the serialize method to handle the serialization in your package, you’ll also have to serialize additional data to restore your items in the right pane and at the right index. And you’ll probably have a delay before you get your items restored.