Loading...
banner plugin Image
woo-image

Web Worker Offloading

By WordPress Performance Team

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.

This functionality is experimental.

In order to opt in a script to be loaded in a worker, simply add worker script data to a registered script. For example, if you have a script registered with the handle of foo, opt-in to offload it to a web worker by doing:

wp_script_add_data( 'foo', 'worker', true );

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.

Otherwise, the plugin currently ships with built-in integrations to offload Google Analytics to a web worker for the following plugin: Rank Math SEO, Site Kit by Google, WooCommerce.

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.

This plugin relies on the Partytown library by Builder.io, released under the MIT license. This library is in beta and there are quite a few open bugs.

The Partytown configuration can be modified via the plwwo_configuration filter. However, not all of the configuration options can be serialized to JSON in this way, for example the resolveUrl configuration is a function.

Other Notable Features

Here are a few other notable features of this free Web Worker Offloading plugin.

check-fill
JavaScript execution
check-fill
Web Worker
check-fill
Performance improvement

FAQ

If you find that your offloaded scripts aren’t working while also seeing a 404 error in the console for a file at /wp-content/plugins/web-worker-offloading/build/partytown-sandbox-sw.html?1727389399791 then it’s likely you have Chrome DevTools open with the “Bypass for Network” toggle enabled in the Application panel.

Contributors and developers

“Web Worker Offloading” is open source software. The following people have contributed to this plugin.

WPS
Exclamation-Image

7.06

Very Good

Star-Image

Ratings

3 out of 5 | 3
History-Image

Version

0.2.1
calendar-Image

Last updated

1 month ago
Star-Image

Active installations

20,000+
Star-Image

WordPress version

7.0 or higher
php-Image

PHP version

7.2 or higher
translate-Image

Languages

7

Tags

Analytics,Javascript,Partytown,Performance,Web Worker