{"id":207001,"date":"2024-10-03T18:57:16","date_gmt":"2024-10-03T18:57:16","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/web-worker-offloading\/"},"modified":"2026-02-27T20:19:13","modified_gmt":"2026-02-27T20:19:13","slug":"web-worker-offloading","status":"publish","type":"plugin","link":"https:\/\/pirate.wordpress.org\/plugins\/web-worker-offloading\/","author":20220395,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"0.2.1","stable_tag":"0.2.1","tested":"7.0","requires":"6.6","requires_php":"7.2","requires_plugins":null,"header_name":"Web Worker Offloading","header_author":"WordPress Performance Team","header_description":"Offload JavaScript execution to a Web Worker.","assets_banners_color":"68bede","last_updated":"2026-02-27 20:19:13","external_support_url":"","external_repository_url":"https:\/\/github.com\/WordPress\/performance","donate_link":"","header_plugin_uri":"https:\/\/github.com\/WordPress\/performance\/issues\/176","header_author_uri":"https:\/\/make.wordpress.org\/performance\/","rating":3,"author_block_rating":0,"active_installs":20000,"downloads":78752,"num_ratings":3,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","faq","changelog"],"tags":{"0.1.0":{"tag":"0.1.0","author":"westonruter","date":"2024-10-03 18:57:07"},"0.1.1":{"tag":"0.1.1","author":"performanceteam","date":"2024-10-21 17:15:24"},"0.2.0":{"tag":"0.2.0","author":"performanceteam","date":"2025-12-02 22:34:52"},"0.2.1":{"tag":"0.2.1","author":"performanceteam","date":"2026-02-27 20:19:13"}},"upgrade_notice":[],"ratings":{"1":0,"2":2,"3":0,"4":0,"5":1},"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":3173091,"resolution":"128x128","location":"assets","locale":""},"icon-256x256.png":{"filename":"icon-256x256.png","revision":3173091,"resolution":"256x256","location":"assets","locale":""},"icon.svg":{"filename":"icon.svg","revision":3173091,"resolution":false,"location":"assets","locale":false}},"assets_banners":{"banner-1544x500.png":{"filename":"banner-1544x500.png","revision":3173091,"resolution":"1544x500","location":"assets","locale":""},"banner-772x250.png":{"filename":"banner-772x250.png","revision":3173091,"resolution":"772x250","location":"assets","locale":""}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["0.1.0","0.1.1","0.2.0","0.2.1"],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[232,229,232387,247,232386],"plugin_category":[36,54],"plugin_contributors":[77594],"plugin_business_model":[216239],"class_list":["post-207001","plugin","type-plugin","status-publish","hentry","plugin_tags-analytics","plugin_tags-javascript","plugin_tags-partytown","plugin_tags-performance","plugin_tags-web-worker","plugin_category-analytics","plugin_category-security-and-spam-protection","plugin_contributors-wordpressdotorg","plugin_business_model-community","plugin_committers-adamsilverstein","plugin_committers-performanceteam","plugin_committers-westonruter"],"banners":{"banner":"https:\/\/ps.w.org\/web-worker-offloading\/assets\/banner-772x250.png?rev=3173091","banner_2x":"https:\/\/ps.w.org\/web-worker-offloading\/assets\/banner-1544x500.png?rev=3173091","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":"https:\/\/ps.w.org\/web-worker-offloading\/assets\/icon.svg?rev=3173091","icon":"https:\/\/ps.w.org\/web-worker-offloading\/assets\/icon.svg?rev=3173091","icon_2x":false,"generated":false},"screenshots":[],"raw_content":"<!--section=description-->\n<p>This plugin offloads JavaScript execution to a Web Worker, improving performance by freeing up the main thread. This should translate into improved <a href=\"https:\/\/web.dev\/articles\/inp\">Interaction to Next Paint<\/a> (INP) scores.<\/p>\n\n<p>\u26a0 <em>This functionality is experimental, and <strong>it is now <a href=\"https:\/\/github.com\/WordPress\/performance\/issues\/2284\">intended to be sunset<\/a><\/strong>.<\/em> \u26a0<\/p>\n\n<p>In order to opt in a script to be loaded in a worker, simply add <code>worker<\/code> script data to a registered script. For example,\nif you have a script registered with the handle of <code>foo<\/code>, opt-in to offload it to a web worker by doing:<\/p>\n\n<pre><code>wp_script_add_data( 'foo', 'worker', true );\n<\/code><\/pre>\n\n<p>Unlike with the script loading strategies (async\/defer), any inline before\/after scripts associated with the worker-offloaded registered script will also be offloaded to the worker, whereas with the script strategies an inline after script would block the script from being delayed.<\/p>\n\n<p>Otherwise, the plugin currently ships with built-in integrations to offload Google Analytics to a web worker for the following plugin:<\/p>\n\n<ul>\n<li><a href=\"https:\/\/wordpress.org\/plugins\/seo-by-rank-math\/\">Rank Math SEO<\/a><\/li>\n<li><a href=\"https:\/\/wordpress.org\/plugins\/google-site-kit\/\">Site Kit by Google<\/a><\/li>\n<li><a href=\"https:\/\/wordpress.org\/plugins\/woocommerce\/\">WooCommerce<\/a><\/li>\n<\/ul>\n\n<p>Please monitor your analytics once activating to ensure all the expected events are being logged. At the same time, monitor your INP scores to check for improvement.<\/p>\n\n<p>This plugin relies on the <a href=\"https:\/\/partytown.builder.io\/\">Partytown \ud83c\udf89<\/a> library by Builder.io, released under the MIT license. This library is in beta and there are quite a few <a href=\"https:\/\/github.com\/BuilderIO\/partytown\/issues?q=is%3Aopen+is%3Aissue+label%3Abug\">open bugs<\/a>.<\/p>\n\n<p>The <a href=\"https:\/\/partytown.builder.io\/configuration\">Partytown configuration<\/a> can be modified via the <code>plwwo_configuration<\/code> filter. For example:<\/p>\n\n<pre><code>&lt;?php\nadd_filter( 'plwwo_configuration', function ( $config ) {\n    $config['mainWindowAccessors'][] = 'wp'; \/\/ Make the wp global available in the worker (e.g. wp.i18n and wp.hooks).\n    return $config;\n} );\n<\/code><\/pre>\n\n<p>However, not all of the configuration options can be serialized to JSON in this way, for example the <code>resolveUrl<\/code> configuration is a function. To specify this, you can add an inline script as follows.<\/p>\n\n<pre><code>&lt;?php\nadd_action(\n    'wp_enqueue_scripts',\n    function () {\n        wp_add_inline_script(\n            'web-worker-offloading',\n            &lt;&lt;&lt;JS\n            window.partytown = {\n                ...(window.partytown || {}),\n                resolveUrl: (url, location, type) =&gt; {\n                    if (type === 'script') {\n                        const proxyUrl = new URL('https:\/\/my-reverse-proxy.example.com\/');\n                        proxyUrl.searchParams.append('url', url.href);\n                        return proxyUrl;\n                    }\n                    return url;\n                },\n            };\n            JS,\n            'before'\n        );\n    }\n);\n<\/code><\/pre>\n\n<p>There are also many configuration options which are not documented, so refer to the <a href=\"https:\/\/github.com\/BuilderIO\/partytown\/blob\/b292a14047a0c12ca05ba97df1833935d42fdb66\/src\/lib\/types.ts#L393-L548\">TypeScript definitions<\/a>.<\/p>\n\n<!--section=faq-->\n<dl>\n<dt id=\"why%20are%20my%20offloaded%20scripts%20not%20working%20and%20i%20see%20a%20404%20error%20in%20the%20console%20for%20%60partytown-sandbox-sw.html%60%3F\"><h3>Why are my offloaded scripts not working and I see a 404 error in the console for `partytown-sandbox-sw.html`?<\/h3><\/dt>\n<dd><p>If you find that your offloaded scripts aren't working while also seeing a 404 error in the console for a file at <code>\/wp-content\/plugins\/web-worker-offloading\/build\/partytown-sandbox-sw.html?1727389399791<\/code> then it's likely you have Chrome DevTools open with the \"Bypass for Network\" toggle enabled in the Application panel.<\/p><\/dd>\n<dt id=\"where%20can%20i%20report%20security%20bugs%3F\"><h3>Where can I report security bugs?<\/h3><\/dt>\n<dd><p>The Performance team and WordPress community take security bugs seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.<\/p>\n\n<p>To report a security issue, please visit the <a href=\"https:\/\/hackerone.com\/wordpress\">WordPress HackerOne<\/a> program.<\/p><\/dd>\n<dt id=\"how%20can%20i%20contribute%20to%20the%20plugin%3F\"><h3>How can I contribute to the plugin?<\/h3><\/dt>\n<dd><p>Contributions are always welcome! Learn more about how to get involved in the <a href=\"https:\/\/make.wordpress.org\/performance\/handbook\/get-involved\/\">Core Performance Team Handbook<\/a>.<\/p>\n\n<p>The <a href=\"https:\/\/github.com\/WordPress\/performance\/tree\/trunk\/plugins\/web-worker-offloading\">plugin source code<\/a> is located in the <a href=\"https:\/\/github.com\/WordPress\/performance\">WordPress\/performance<\/a> repo on GitHub.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>0.2.1<\/h4>\n\n<ul>\n<li>Intend to sunset. (<a href=\"https:\/\/github.com\/WordPress\/performance\/pull\/2404\">2404<\/a>)<\/li>\n<\/ul>\n\n<h4>0.2.0<\/h4>\n\n<p><strong>Enhancements<\/strong><\/p>\n\n<ul>\n<li>Integrate Web Worker Offloading with Google Site Kit. (<a href=\"https:\/\/github.com\/WordPress\/performance\/pull\/1686\">1686<\/a>)<\/li>\n<li>Integrate Web Worker Offloading with Rank Math SEO. (<a href=\"https:\/\/github.com\/WordPress\/performance\/pull\/1685\">1685<\/a>)<\/li>\n<li>Serve unminified scripts when <code>SCRIPT_DEBUG<\/code> is enabled. (<a href=\"https:\/\/github.com\/WordPress\/performance\/pull\/1643\">1643<\/a>)<\/li>\n<\/ul>\n\n<p><strong>Bug Fixes<\/strong><\/p>\n\n<ul>\n<li>Fix tracking events like add_to_cart in WooCommerce integration. (<a href=\"https:\/\/github.com\/WordPress\/performance\/pull\/1740\">1740<\/a>)<\/li>\n<\/ul>\n\n<h4>0.1.1<\/h4>\n\n<p><strong>Enhancements<\/strong><\/p>\n\n<ul>\n<li>Add Web Worker Offloading meta generator. (<a href=\"https:\/\/github.com\/WordPress\/performance\/pull\/1598\">1598<\/a>)<\/li>\n<\/ul>\n\n<h4>0.1.0<\/h4>\n\n<ul>\n<li>Initial release.<\/li>\n<\/ul>","raw_excerpt":"Offloads select JavaScript execution to a Web Worker to reduce work on the main thread and improve the Interaction to Next Paint (INP) metric.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/207001","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=207001"}],"author":[{"embeddable":true,"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/performanceteam"}],"wp:attachment":[{"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=207001"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=207001"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=207001"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=207001"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=207001"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/pirate.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=207001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}