Performance Optimization of Extensions

298 views
Skip to first unread message

Chandrasekhar Dwivedi

unread,
Jan 10, 2023, 1:30:28 AM1/10/23
to chromium-...@chromium.org
Hi Guys,

I am new to the world of extension development. I wanted to know if there are any standard tools you guys use to optimize extensions for performance on Chromium browsers. Also do these browsers share any performance related insights from the users side? As in how the extension is performing or impacting the performance or user devices?

--
Thanks and Regards
Chandrasekhar Dwivedi

wOxxOm

unread,
Jan 10, 2023, 4:18:11 AM1/10/23
to Chromium Extensions, chandrasek...@gmail.com
There is no dedicated API for extensions. You can use the standard tools like the built-in devtools Timeline to profile the performance while developing and `window.performance` API to gather metrics during runtime.

The standard performance advices also apply e.g. import code on demand instead of using huge all-in-one bundles, this is particularly important for a content script that runs in all web pages. Chrome doesn't use code compilation cache for extension scripts so big scripts are recompiled in every tab thus slowing down page load process and draining the battery. Also, if the content script is only necessary after the user clicked your extension then don't declare it in `content_scripts` section, instead use chrome.scripting.executeScript to run it on demand.

There's one area to pay special attention now that ManifestV3 has removed the persistent background scripts: resource drain due to frequent restarting of the background script in case it observes frequent events like chrome.tabs.onUpdated or responds to messages from content scripts running in every tab, especially if the script is big and takes a long time to initialize the state. Chromium team hasn't yet acknowledged this problem exists, so you'll have to address it yourself e.g. rewrite the logic to initialize on demand, import code on demand, maybe prolong the lifetime of the background script to reduce the number of restarts during the day, maybe even offload some (or all) of the code to a web_accessible_resources iframe inside the web page.

Chandrasekhar Dwivedi

unread,
Jan 11, 2023, 11:16:13 AM1/11/23
to wOxxOm, Chromium Extensions
Thanks a ton!
Typically, what's the process of publishing an extension to Edge or Chrome once development is complete?

Deco

unread,
Jan 20, 2023, 7:35:55 AM1/20/23
to Chandrasekhar Dwivedi, wOxxOm, Chromium Extensions
In regards to Chrome, simply zip up the source code files as you normally would in its unloaded local format. Afterwards you go to the Chrome Web Store, fill out the developer documentation, pay the fee, and then upload the ZIP file. 

Note that there are strict standards you must adhere to when publishing extensions, and it is in your interest to be familiar with them before publishing an extension. You can find them here: https://support.google.com/chrome/a/answer/9639925?hl=en

There are additional criteria such as image dimensions sizes and what not. 

Documentation for porting a Chrome extension to Edge for publishing is available here: https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/developer-guide/port-chrome-extension

Thanks,
Decklin 

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/CAArSMJJkEhrk3bfg58oGPN6WwsVTor6m1-aRwrvymb4xutF3Bg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages