Optimize extension activation
See original GitHub issueHey this extension looks great!
For activationEvents try to avoid using *
. Using *
means this extension will startup and activate even if someone is not using it. It will also incur a (albeit small) startup cost for users.
As this extension seems to be command driven you can put the commands in there instead, that way it won’t slow down performance when not in use. More info here: https://code.visualstudio.com/api/references/activation-events#Start-up
If you open a directory in VS Code, and that directory represents a swing, then the swing environment will be automatically launched.
I’m not sure how you detect this but you can have the extension activate if a certain file is in the workspace (there’s an example of that here) or if there’s really other option onStartupFinished
may be better
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Just pushed an extension update that activates using
onStartupFinished
, when a command is run, or when a workspace is opened that contains acodeswing.json
file at the root. Thanks for the feedback and let me know if you have any other feedback!The reason I went with
*
is because the logic for detecting a “swing” workspace is dynamic (e.g. other extensions can extend CodeSwing), and therefore, a static list ofworkspaceContains
conditions wouldn’t be entirely sufficient.Additionally, CodeSwing exports an API for other extensions to use (e.g. GistPad), and since there’s no activation event for other extensions trying to use your API, these consumers would need to manually check if CodeSwing was activated, and if not, activate it. That’s definitely not difficult to do, but I wanted to keep things simple since this extension is super new, and I’m exploring integrations with various folks.
Since the
onStartupFinished
event doesn’t guarantee when it will be triggered, I was also a little hesitant to relying on it, since it could introduce seconds of latency when trying to open a swing workspace (depending on the extensions/etc. the user has). Once again, not the end of the world. But using*
provides a couple of nice properties, that couldn’t be fully emulated with other activation events.Out of curiosity: are you seeing CodeSwing impact your startup time? Or did you just see the activation event in the extension details page? I’ll do some profiling to see how to further streamline startup, since it should be pretty negligible. And I’ll play around with
onStartupFinished
to see how it “feels” across different usage scenarios.