question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Optimize extension activation

See original GitHub issue

Hey 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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lostintangentcommented, Jan 26, 2021

Just pushed an extension update that activates using onStartupFinished, when a command is run, or when a workspace is opened that contains a codeswing.json file at the root. Thanks for the feedback and let me know if you have any other feedback!

1reaction
lostintangentcommented, Jan 16, 2021

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 of workspaceContains 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Activation events - Optimize Resource Hub - Google Support
Create your experience (A/B, multivariate, redirect test, or personalization) · Navigate to Settings > Activation event on the experience details page · Click ......
Read more >
VS Code Performance – How to Optimize Visual Studio Code ...
The * Activation Event will activate an extension when VS Code starts up. These extensions will always be active. This impacts the startup...
Read more >
Optimize Visual Studio Code - Technoholic
Extension Activation Stats section details the performance of the extensions. A god idea is to focus on extensions with the longest times and ......
Read more >
Optimize activationEvents in package.json #1097 - GitHub
Currently extension activates by onDebug event. That means that it can be activated by initiating debugging from other extensions.
Read more >
Optimize packaged extension (#453) · Issues - GitLab
Optimize packaged extension ... Currently, the packaged extension contains ~3500 files: ... Load Code, Call Activate, Finish Activate ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found