{"id":3515,"date":"2025-02-14T16:44:19","date_gmt":"2025-02-14T16:44:19","guid":{"rendered":"https:\/\/s-o-s.net\/web-worker-offloading\/"},"modified":"2025-02-14T16:44:19","modified_gmt":"2025-02-14T16:44:19","slug":"web-worker-offloading","status":"publish","type":"post","link":"https:\/\/s-o-s.net\/en_gb\/web-worker-offloading\/","title":{"rendered":"Web Worker Offloading"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<article id=\"post-207001\" class=\"alignwide 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-performanceteam plugin_committers-westonruter\">\n<div class=\"plugin-banner\" id=\"plugin-banner-web-worker-offloading\"><\/div>\n<header class=\"plugin-header\">\n<div class=\"entry-heading-container\">\n<div>\n<div class=\"entry-thumbnail\">\n\t\t\t\t\t<img decoding=\"async\" class=\"plugin-icon\" src=\"https:\/\/ps.w.org\/web-worker-offloading\/assets\/icon.svg?rev=3173091\" alt=\"\">\t\t\t\t<\/div>\n<div>\n<h1 class=\"plugin-title\">Web Worker Offloading<\/h1>\n<p>\t\t\t\t\t<span class=\"byline\">By <span class=\"author vcard\"><a target=\"_blank\" class=\"url fn n\" href=\"https:\/\/profiles.wordpress.org\/performanceteam\/\" rel=\"noopener\">performanceteam<\/a><\/span><\/span>\n\t\t\t\t<\/div>\n<\/p><\/div>\n<div class=\"plugin-actions\">\n<div class=\"wp-block-button is-small plugin-download download-button\"><a target=\"_blank\" class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/downloads.wordpress.org\/plugin\/web-worker-offloading.0.2.0.zip\" rel=\"noopener\">Download<\/a><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/header>\n<p><!-- .entry-header --><\/p>\n<p>\t<span id=\"description\"><\/span><br \/>\n\t<span id=\"reviews\"><\/span><br \/>\n\t<span id=\"installation\"><\/span><br \/>\n\t<span id=\"developers\"><\/span><br \/>\n\t<span id=\"advanced\" class=\"\"><\/span><br \/>\n\t<span id=\"section-links\"><\/p>\n<ul class=\"tabs clear\">\n<li id=\"tablink-description\"><a target=\"_blank\" href=\"https:\/\/wordpress.org\/plugins\/web-worker-offloading\/#description\" rel=\"noopener\">Details<\/a><\/li>\n<li id=\"tablink-reviews\"><a target=\"_blank\" href=\"https:\/\/wordpress.org\/plugins\/web-worker-offloading\/#reviews\" rel=\"noopener\">Reviews<\/a><\/li>\n<li id=\"tablink-developers\"><a target=\"_blank\" href=\"https:\/\/wordpress.org\/plugins\/web-worker-offloading\/#developers\" rel=\"noopener\">Development<\/a><\/li>\n<\/ul>\n<div id=\"link-support\">\n\t\t\t<a target=\"_blank\" href=\"https:\/\/wordpress.org\/support\/plugin\/web-worker-offloading\/\" rel=\"noopener\">Support<\/a>\n\t\t<\/div>\n<p>\t<\/span><br \/>\n\t<script type=\"text\/javascript\">if ( '#changelog' == window.location.hash ) { window.setTimeout( function() { window.location.hash=\"#developers\"; }, 10 ); }<\/script><\/p>\n<div class=\"entry-content\">\n<div id=\"tab-description\" class=\"plugin-description section\">\n<h2 id=\"description-header\">Description<\/h2>\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 target=\"_blank\" href=\"https:\/\/web.dev\/articles\/inp\" rel=\"nofollow ugc noopener\">Interaction to Next Paint<\/a> (INP) scores.<\/p>\n<p>\u26a0 <em>This functionality is experimental.<\/em> \u26a0<\/p>\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,<br \/>\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<pre><code>wp_script_add_data( 'foo', 'worker', true );\n<\/code><\/pre>\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<p>Otherwise, the plugin currently ships with built-in integrations to offload Google Analytics to a web worker for the following plugin:<\/p>\n<ul>\n<li><a target=\"_blank\" href=\"https:\/\/wordpress.org\/plugins\/seo-by-rank-math\/\" rel=\"ugc noopener\">Rank Math SEO<\/a><\/li>\n<li><a target=\"_blank\" href=\"https:\/\/wordpress.org\/plugins\/google-site-kit\/\" rel=\"ugc noopener\">Site Kit by Google<\/a><\/li>\n<li><a target=\"_blank\" href=\"https:\/\/wordpress.org\/plugins\/woocommerce\/\" rel=\"ugc noopener\">WooCommerce<\/a><\/li>\n<\/ul>\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<p>This plugin relies on the <a target=\"_blank\" href=\"https:\/\/partytown.builder.io\/\" rel=\"nofollow ugc noopener\" class=\"broken_link\">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 target=\"_blank\" href=\"https:\/\/github.com\/BuilderIO\/partytown\/issues?q=is%3Aopen+is%3Aissue+label%3Abug\" rel=\"nofollow ugc noopener\">open bugs<\/a>.<\/p>\n<p>The <a target=\"_blank\" href=\"https:\/\/partytown.builder.io\/configuration\" rel=\"nofollow ugc noopener\" class=\"broken_link\">Partytown configuration<\/a> can be modified via the <code>plwwo_configuration<\/code> filter. For example:<\/p>\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<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<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<p>There are also many configuration options which are not documented, so refer to the <a target=\"_blank\" href=\"https:\/\/github.com\/BuilderIO\/partytown\/blob\/b292a14047a0c12ca05ba97df1833935d42fdb66\/src\/lib\/types.ts#L393-L548\" rel=\"nofollow ugc noopener\">TypeScript definitions<\/a>.<\/p>\n<\/div>\n<div id=\"faq\" class=\"plugin-faq section\">\n<h2 id=\"faq-header\">FAQ<\/h2>\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\">\n<h3>Why are my offloaded scripts not working and I see a 404 error in the console for `partytown-sandbox-sw.html`?<\/h3>\n<\/dt>\n<dd>\n<p>If you find that your offloaded scripts aren\u2019t 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\u2019s likely you have Chrome DevTools open with the \u201cBypass for Network\u201d toggle enabled in the Application panel.<\/p>\n<\/dd>\n<dt id=\"where%20can%20i%20report%20security%20bugs%3F\">\n<h3>Where can I report security bugs?<\/h3>\n<\/dt>\n<dd>\n<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<p>To report a security issue, please visit the <a target=\"_blank\" href=\"https:\/\/hackerone.com\/wordpress\" rel=\"nofollow ugc noopener\">WordPress HackerOne<\/a> program.<\/p>\n<\/dd>\n<dt id=\"how%20can%20i%20contribute%20to%20the%20plugin%3F\">\n<h3>How can I contribute to the plugin?<\/h3>\n<\/dt>\n<dd>\n<p>Contributions are always welcome! Learn more about how to get involved in the <a target=\"_blank\" href=\"https:\/\/make.wordpress.org\/performance\/handbook\/get-involved\/\" rel=\"nofollow ugc noopener\">Core Performance Team Handbook<\/a>.<\/p>\n<p>The <a target=\"_blank\" href=\"https:\/\/github.com\/WordPress\/performance\/tree\/trunk\/plugins\/web-worker-offloading\" rel=\"nofollow ugc noopener\">plugin source code<\/a> is located in the <a target=\"_blank\" href=\"https:\/\/github.com\/WordPress\/performance\" rel=\"nofollow ugc noopener\">WordPress\/performance<\/a> repo on GitHub.<\/p>\n<\/dd>\n<\/dl>\n<\/div>\n<div id=\"tab-reviews\" class=\"plugin-reviews section\">\n<h2 id=\"reviews-header\">Reviews<\/h2>\n<div class=\"plugin-reviews\">\n<article class=\"plugin-review\">\n<div class=\"review-avatar\">\n\t\t\t\t\t\t<img decoding=\"async\" alt=\"\" src=\"https:\/\/secure.gravatar.com\/avatar\/392fc315ceff5ccb972985e4655d19d32e636fd93dca2711ba140c29844d09db?s=60&amp;d=retro&amp;r=g\" srcset=\"https:\/\/secure.gravatar.com\/avatar\/392fc315ceff5ccb972985e4655d19d32e636fd93dca2711ba140c29844d09db?s=120&amp;d=retro&amp;r=g 2x\" class=\"avatar avatar-60 photo\" height=\"60\" width=\"60\">\t\t\t\t\t<\/div>\n<div class=\"review\">\n<header>\n<div class=\"header-top\">\n<div class=\"wporg-ratings\" aria-label=\"2 out of 5 stars\" data-title-template=\"%s out of 5 stars\" data-rating=\"2\" style=\"color:#ffb900;\"><span class=\"dashicons dashicons-star-filled\"><\/span><span class=\"dashicons dashicons-star-filled\"><\/span><span class=\"dashicons dashicons-star-empty\"><\/span><span class=\"dashicons dashicons-star-empty\"><\/span><span class=\"dashicons dashicons-star-empty\"><\/span><\/div>\n<h3 class=\"review-title\"><a target=\"_blank\" class=\"url\" href=\"https:\/\/wordpress.org\/support\/topic\/google-analytics-and-this-does-not-work\/\" rel=\"noopener\">Google Analytics and This = Does not work!<\/a><\/h3>\n<\/p><\/div>\n<div class=\"header-bottom\">\n\t\t\t\t\t\t\t\t<span class=\"review-author author vcard\"><a target=\"_blank\" href=\"https:\/\/profiles.wordpress.org\/wazone\/\" title=\"Posts by Kenneth\" rel=\"author noopener\">Kenneth<\/a><\/span><br \/>\n\t\t\t\t\t\t\t\t<span class=\"review-date\">January 12, 2025<\/span>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n<\/header>\n<div class=\"review-content\">Problems with Google Analytics and Google Tag ManagerTested: 1 week. While Enabled: No hits, no recorded live users\/users in Google Analytics. Google Tag Manager also didnt get to connect to the site. \u2013 Clarity did record users live, and page hits. This is because Clarity is not included in the built-in integrationWhile disabled: Google Analytics got hits right away \u2013 same with Google Tag Manager.<\/div>\n<\/p><\/div>\n<\/article><\/div>\n<p>\t\t<a target=\"_blank\" class=\"reviews-link\" href=\"https:\/\/wordpress.org\/support\/plugin\/web-worker-offloading\/reviews\/\" rel=\"noopener\"><br \/>\n\t\t\tRead all 1 review\t\t<\/a><\/div>\n<div id=\"tab-developers\" class=\"plugin-developers section\">\n<h2 id=\"developers-header\">Contributors &amp; Developers<\/h2>\n<div class=\"plugin-contributors\">\n<p>\u201cWeb Worker Offloading\u201d is open source software. The following people have contributed to this plugin.<\/p>\n<p><span class=\"screen-reader-text\">Contributors<\/span><\/p>\n<ul id=\"contributors-list\" class=\"contributors-list\">\n<li>\n\t\t\t\t<img decoding=\"async\" alt=\"\" src=\"https:\/\/secure.gravatar.com\/avatar\/178f40079143ff7464125e4fbc88e62024a16442920a6a3d6dfa3d7e626be20d?s=32&amp;d=mm&amp;r=g\" srcset=\"https:\/\/secure.gravatar.com\/avatar\/178f40079143ff7464125e4fbc88e62024a16442920a6a3d6dfa3d7e626be20d?s=64&amp;d=mm&amp;r=g 2x\" class=\"avatar avatar-32 photo\" height=\"32\" width=\"32\">\t\t\t\t<a target=\"_blank\" href=\"https:\/\/profiles.wordpress.org\/wordpressdotorg\/\" rel=\"noopener\"><br \/>\n\t\t\t\t\tWordPress.org\t\t\t\t<\/a>\n\t\t\t<\/li>\n<\/ul><\/div>\n<div class=\"plugin-development\">\n<p>\u201cWeb Worker Offloading\u201d has been translated into 3 locales. Thank you to <a target=\"_blank\" href=\"https:\/\/translate.wordpress.org\/projects\/wp-plugins\/web-worker-offloading\/contributors\" rel=\"noopener\">the translators<\/a> for their contributions.<\/p>\n<p><a target=\"_blank\" href=\"https:\/\/translate.wordpress.org\/projects\/wp-plugins\/web-worker-offloading\" rel=\"noopener\">Translate \u201cWeb Worker Offloading\u201d into your language.<\/a><\/p>\n<h3>Interested in development?<\/h3>\n<p><a target=\"_blank\" href=\"https:\/\/plugins.trac.wordpress.org\/browser\/web-worker-offloading\/\" rel=\"noopener\" class=\"broken_link\">Browse the code<\/a>, check out the <a target=\"_blank\" href=\"https:\/\/plugins.svn.wordpress.org\/web-worker-offloading\/\" rel=\"noopener\">SVN repository<\/a>, or subscribe to the <a target=\"_blank\" href=\"https:\/\/plugins.trac.wordpress.org\/log\/web-worker-offloading\/\" rel=\"noopener\" class=\"broken_link\">development log<\/a> by <a target=\"_blank\" href=\"https:\/\/plugins.trac.wordpress.org\/log\/web-worker-offloading\/?limit=100&amp;mode=stop_on_copy&amp;format=rss\" rel=\"noopener\" class=\"broken_link\">RSS<\/a>.<\/p>\n<\/div>\n<\/div>\n<div id=\"tab-changelog\" class=\"plugin-changelog section\">\n<h2 id=\"changelog-header\">Changelog<\/h2>\n<h4>0.2.0<\/h4>\n<p><strong>Enhancements<\/strong><\/p>\n<ul>\n<li>Integrate Web Worker Offloading with Google Site Kit. (<a target=\"_blank\" href=\"https:\/\/github.com\/WordPress\/performance\/pull\/1686\" rel=\"nofollow ugc noopener\">1686<\/a>)<\/li>\n<li>Integrate Web Worker Offloading with Rank Math SEO. (<a target=\"_blank\" href=\"https:\/\/github.com\/WordPress\/performance\/pull\/1685\" rel=\"nofollow ugc noopener\">1685<\/a>)<\/li>\n<li>Serve unminified scripts when <code>SCRIPT_DEBUG<\/code> is enabled. (<a target=\"_blank\" href=\"https:\/\/github.com\/WordPress\/performance\/pull\/1643\" rel=\"nofollow ugc noopener\">1643<\/a>)<\/li>\n<\/ul>\n<p><strong>Bug Fixes<\/strong><\/p>\n<ul>\n<li>Fix tracking events like add_to_cart in WooCommerce integration. (<a target=\"_blank\" href=\"https:\/\/github.com\/WordPress\/performance\/pull\/1740\" rel=\"nofollow ugc noopener\">1740<\/a>)<\/li>\n<\/ul>\n<h4>0.1.1<\/h4>\n<p><strong>Enhancements<\/strong><\/p>\n<ul>\n<li>Add Web Worker Offloading meta generator. (<a target=\"_blank\" href=\"https:\/\/github.com\/WordPress\/performance\/pull\/1598\" rel=\"nofollow ugc noopener\">1598<\/a>)<\/li>\n<\/ul>\n<h4>0.1.0<\/h4>\n<ul>\n<li>Initial release.<\/li>\n<\/ul>\n<\/div><\/div>\n<p><!-- .entry-content --><\/p>\n<p>\t<!-- .entry-meta --><br \/>\n<\/article>\n<p><br \/>\n<br \/><a href=\"https:\/\/wordpress.org\/plugins\/web-worker-offloading\/\" target=\"_blank\" rel=\"noopener\">Source link <\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Web Worker Offloading By performanceteam Download Details Reviews Development Support Description This plugin offloads JavaScript execution to a Web Worker, improving performance by freeing up the main thread. This should translate into improved Interaction to Next Paint (INP) scores. \u26a0 This functionality is experimental. \u26a0 In order to opt in a script to be loaded [&hellip;]<\/p>","protected":false},"author":6,"featured_media":3516,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"give_campaign_id":0,"footnotes":""},"categories":[1933,39,40],"tags":[2414,2350,2413],"class_list":["post-3515","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-community-plugin","category-lite-version","category-wp-plugin-solution","tag-offloading","tag-web","tag-worker"],"acf":[],"fifu_image_url":"https:\/\/ps.w.org\/web-worker-offloading\/assets\/banner-772x250.png?rev=3173091","_links":{"self":[{"href":"https:\/\/s-o-s.net\/en_gb\/wp-json\/wp\/v2\/posts\/3515","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/s-o-s.net\/en_gb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/s-o-s.net\/en_gb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/s-o-s.net\/en_gb\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/s-o-s.net\/en_gb\/wp-json\/wp\/v2\/comments?post=3515"}],"version-history":[{"count":0,"href":"https:\/\/s-o-s.net\/en_gb\/wp-json\/wp\/v2\/posts\/3515\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/s-o-s.net\/en_gb\/wp-json\/wp\/v2\/media\/3516"}],"wp:attachment":[{"href":"https:\/\/s-o-s.net\/en_gb\/wp-json\/wp\/v2\/media?parent=3515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/s-o-s.net\/en_gb\/wp-json\/wp\/v2\/categories?post=3515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/s-o-s.net\/en_gb\/wp-json\/wp\/v2\/tags?post=3515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}