{"id":2231,"date":"2026-05-01T08:00:00","date_gmt":"2026-05-01T07:00:00","guid":{"rendered":"https:\/\/www.stefanvd.net\/blog\/?p=2231"},"modified":"2026-03-31T16:48:37","modified_gmt":"2026-03-31T15:48:37","slug":"how-to-reduce-memory-cpu-usage","status":"publish","type":"post","link":"https:\/\/www.stefanvd.net\/blog\/2026\/05\/01\/how-to-reduce-memory-cpu-usage\/","title":{"rendered":"3 Proven Ways to Dramatically Reduce Memory &amp; CPU Usage in Chrome Extensions"},"content":{"rendered":"\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><p>Table of Contents<\/p><nav><ul><li><a href=\"#scripts\">Optimizing Scripts<\/a><ul><li><a href=\"#be-careful-with-content-scripts\">Be Careful with Content Scripts<\/a><\/li><li><a href=\"#avoid-heavy-set-interval-usage\">Avoid Heavy setInterval Usage<\/a><\/li><li><a href=\"#use-chrome-alarms-for-scheduled-tasks\">Use chrome.alarms for Scheduled Tasks<\/a><\/li><\/ul><\/li><li><a href=\"#debug\">Testing Performance<\/a><ul><li><a href=\"#debug-with-chrome-inspector\">Debug with Chrome Inspector<\/a><\/li><li><a href=\"#acid-3-test\">Acid3 test<\/a><\/li><li><a href=\"#lighthouse\">Lighthouse<\/a><\/li><\/ul><\/li><li><a href=\"#resources\">Resources<\/a><\/li><li><a href=\"#conclusion\">Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n<p>One of the most common performance issues in Chrome extensions comes from loading and running code when it is not actually needed. Poorly optimized browser extensions can consume unnecessary memory, wake up the CPU too often, and slow down the browser. Luckily, there are a few best practices that can dramatically reduce memory and CPU resource usage.<\/p>\n\n\n\n<p>This article is written for developers looking to reduce memory usage and CPU load in their existing browser extensions. It focuses on two core principles: optimizing scripts and testing performance through proper debugging.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"scripts\">Optimizing Scripts<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"be-careful-with-content-scripts\">Be Careful with Content Scripts<\/h3>\n\n\n\n<p>Content scripts are injected into web pages, which means they can easily become expensive if you load them everywhere. A common mistake is loading <code>content.js<\/code> on <em>all<\/em> websites, even when the browser extension only needs to work on specific domains. Every injected script adds memory usage and execution overhead.<\/p>\n\n\n\n<p>Instead, only inject content scripts where they are truly required. For example, if your browser extension only interacts with your own website, limit the <code>matches<\/code> field in <code>manifest.json<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  \"content_scripts\": &#91;\n    {\n      \"matches\": &#91;\"*:\/\/*.stefanvd.net\/*\"],\n      \"js\": &#91;\"scripts\/constants.js\", \"scripts\/content.js\"]\n    }\n  ],<\/code><\/pre>\n\n\n\n<p>In this case, my <a href=\"https:\/\/chromewebstore.google.com\/detail\/font-size-increase-for-go\/ombpcpigmndepfckcifdblemkabaoihk\" target=\"_blank\" rel=\"noopener\">Font-Size Increase browser extension<\/a> and <a href=\"https:\/\/chromewebstore.google.com\/detail\/font-size-decrease-for-go\/mpajngnpcmjjeoflljdjpnehcfaldcia\" target=\"_blank\" rel=\"noopener\">Font-Size Decrease browser extension<\/a> only runs on <code>stefanvd.net<\/code>, avoiding unnecessary script injection on unrelated pages like Google Search or the YouTube video website.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"598\" src=\"https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/visual-studio-code-manifest-json-file-1024x598.webp\" alt=\"Visual Studio Code app on the manifest.json file to reduce memory usage, and limit the content script to load only on a specific website\" class=\"wp-image-2316\" srcset=\"https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/visual-studio-code-manifest-json-file-1024x598.webp 1024w, https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/visual-studio-code-manifest-json-file-300x175.webp 300w, https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/visual-studio-code-manifest-json-file-768x449.webp 768w, https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/visual-studio-code-manifest-json-file-1536x897.webp 1536w, https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/visual-studio-code-manifest-json-file-2048x1196.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Visual Studio Code app on the manifest.json file to reduce memory usage, and limit the content script to load only on a specific website<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"avoid-heavy-set-interval-usage\">Avoid Heavy <code>setInterval<\/code> Usage<\/h3>\n\n\n\n<p>Using <code>setInterval<\/code> in content scripts or background scripts can easily cause constant CPU wake-ups, even when nothing needs to be done. This is especially problematic if the interval runs every few milliseconds or seconds across multiple tabs.<\/p>\n\n\n\n<p>Whenever possible, replace <code>setInterval<\/code> with event-based logic. If you need periodic execution, consider using <code>chrome.alarms<\/code>. Alarms are managed by Chrome itself and are far more efficient, especially for background tasks that do not need high-frequency updates.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"use-chrome-alarms-for-scheduled-tasks\">Use <code>chrome.alarms<\/code> for Scheduled Tasks<\/h3>\n\n\n\n<p><code>chrome.alarms<\/code> allows your browser extension to run code only when necessary. For example, checking installation state, syncing data, or cleaning up storage can all be scheduled efficiently without keeping scripts active all the time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"debug\">Testing Performance<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"debug-with-chrome-inspector\">Debug with Chrome Inspector<\/h3>\n\n\n\n<p>Finally, always profile your browser extension using Chrome DevTools. Inspect content scripts, background pages, and service workers to see memory usage and CPU activity. This helps identify unnecessary scripts, frequent timers, and performance bottlenecks before users feel them.<\/p>\n\n\n\n<p>Optimizing these areas keeps your browser extension fast, lightweight, and friendly to users\u2019 browsers.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"acid-3-test\">Acid3 test<\/h3>\n\n\n\n<p>Back in 2011, the ACID3 test was commonly used to measure how well a browser supported web standards. Today, in 2026, it is no longer a reliable benchmark for modern web browsers such as Google Chrome, Firefox, Opera, Safari, and Microsoft Edge.<\/p>\n\n\n\n<p>At that time, Chrome extensions running in the background can interfere with this test. Because of that, the result may not show a perfect <strong>100\/100<\/strong>, but instead a lower score, such as <strong>96\/100<\/strong> or another reduced value.<\/p>\n\n\n\n<p>You can run the test here:<br><a href=\"http:\/\/acid3.acidtests.org\/\" target=\"_blank\" rel=\"noopener\">http:\/\/acid3.acidtests.org<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"756\" src=\"https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/acid3-test-1024x756.webp\" alt=\"\" class=\"wp-image-2304\" srcset=\"https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/acid3-test-1024x756.webp 1024w, https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/acid3-test-300x221.webp 300w, https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/acid3-test-768x567.webp 768w, https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/acid3-test.webp 1480w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>First, run the ACID3 test with all your Chrome extensions enabled. Then disable your extensions and run the test again. If the score returns to <strong>100\/100<\/strong> after disabling them, it means one of your Chrome extensions is injecting JavaScript or CSS that conflicts with the test.<\/p>\n\n\n\n<p>In that case, you will need to review and adjust the injected code in your Chrome extension to prevent the issue.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"lighthouse\">Lighthouse<\/h3>\n\n\n\n<p>Today, we can use Google Chrome\u2019s built-in Lighthouse tool to analyze a website\u2019s performance. Lighthouse checks key best practices such as page speed, accessibility, SEO, and more.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"556\" src=\"https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/lighthouse-home-1024x556.webp\" alt=\"Lighthouse score panel\" class=\"wp-image-2310\" srcset=\"https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/lighthouse-home-1024x556.webp 1024w, https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/lighthouse-home-300x163.webp 300w, https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/lighthouse-home-768x417.webp 768w, https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/lighthouse-home-1536x834.webp 1536w, https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/lighthouse-home-2048x1113.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Lighthouse score panel<\/figcaption><\/figure>\n\n\n\n<p>In the Performance tab, you can also see which Chrome extensions are interfering with the web page. For example, this trace shows that Grammarly (<code>kbfnbcaeplbcioakkpcpgfkobkghlhen<\/code>) causes a <strong>203 ms <\/strong>delay, which leads to a longer page load time until the Chrome extension finishes executing.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"556\" src=\"https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/lighthouse-extension-grammarly-1024x556.webp\" alt=\"Lighthouse performance at the 3rd party panel\" class=\"wp-image-2309\" srcset=\"https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/lighthouse-extension-grammarly-1024x556.webp 1024w, https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/lighthouse-extension-grammarly-300x163.webp 300w, https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/lighthouse-extension-grammarly-768x417.webp 768w, https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/lighthouse-extension-grammarly-1536x834.webp 1536w, https:\/\/www.stefanvd.net\/blog\/wp-content\/uploads\/2026\/01\/lighthouse-extension-grammarly-2048x1112.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Lighthouse performance at the 3rd party panel<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"resources\">Resources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Acid3\" target=\"_blank\" rel=\"noopener\">Wikipedia about the Acid3<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/learn.microsoft.com\/en-us\/microsoft-edge\/extensions\/developer-guide\/minimize-page-load-time-impact\" target=\"_blank\" rel=\"noopener\">Microsoft developer guide about minimizing an extension&#8217;s impact on page load time<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p id=\"conclusion\">Reducing memory and CPU usage in a browser extension is not about cutting features, but about running code only when it truly matters. By limiting content script injection to the required websites, avoiding unnecessary file loading, and replacing constant <code>setInterval<\/code> timers with event-driven logic or <code>chrome.alarms<\/code>, you can significantly improve your browser extension\u2019s performance.<\/p>\n\n\n\n<p>Small changes, such as narrowing <code>matches<\/code> in your <code>manifest.json<\/code> or profiling scripts with Chrome DevTools, can have a big impact on browser responsiveness and battery life. These optimizations help your browser extension feel lightweight and reliable, especially for users who run many tabs at once.<\/p>\n\n\n\n<p>Taking the time to optimize resource usage not only improves user experience but also builds trust. Users are far more likely to keep a browser extension installed when it behaves efficiently and respectfully in the background.<\/p>\n\n\n\n<p>If you found this guide helpful and would like to support continued work on browser extensions and developer education, consider supporting my work. <a href=\"https:\/\/www.stefanvd.net\/donate\/\">Every contribution, big or small, helps me create more practical guides like this<\/a>. Thank you for your support!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the most common performance issues in Chrome extensions comes from loading and running code when it is not actually needed. Poorly optimized browser extensions can consume unnecessary memory, wake up the CPU too often, and slow down the browser. Luckily, there are a few best practices that can dramatically reduce memory and CPU [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2321,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,9],"tags":[],"class_list":["post-2231","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-browser","category-programming"],"_links":{"self":[{"href":"https:\/\/www.stefanvd.net\/blog\/wp-json\/wp\/v2\/posts\/2231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.stefanvd.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.stefanvd.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.stefanvd.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.stefanvd.net\/blog\/wp-json\/wp\/v2\/comments?post=2231"}],"version-history":[{"count":18,"href":"https:\/\/www.stefanvd.net\/blog\/wp-json\/wp\/v2\/posts\/2231\/revisions"}],"predecessor-version":[{"id":2381,"href":"https:\/\/www.stefanvd.net\/blog\/wp-json\/wp\/v2\/posts\/2231\/revisions\/2381"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.stefanvd.net\/blog\/wp-json\/wp\/v2\/media\/2321"}],"wp:attachment":[{"href":"https:\/\/www.stefanvd.net\/blog\/wp-json\/wp\/v2\/media?parent=2231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.stefanvd.net\/blog\/wp-json\/wp\/v2\/categories?post=2231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.stefanvd.net\/blog\/wp-json\/wp\/v2\/tags?post=2231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}