Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add web worker offloading plugin #1247

Open
wants to merge 75 commits into
base: trunk
Choose a base branch
from
Open

Conversation

thelovekesh
Copy link
Member

@thelovekesh thelovekesh commented May 24, 2024

Summary

Fixes #176

Previously: #556

Relevant technical choices

  • Add Web Worker Offloading standalone plugin which allows running scripts within the worker thread with the help of the Partytown library.
  • Add the wwo_configuration filter which can be used to update web worker configurations.

Testing steps

  • Enable this performance plugin or use wp-env in which this plugin is enabled by default on this branch.

  • Add a JS script with web-worker-offloader as a dependency. When the page is loaded, the JS script should be loaded within the web worker.

    function enqueue_non_critical_js() {
        wp_enqueue_script(
      	  'non-critical-js',
      	  '/path/to/non-critical.js',
      	  array( 'web-worker-offloader' ), // Note the `web-worker-offloader` being added as a dep
      	  '1.0.0',
      	  true
        );
    }
    add_action( 'wp_enqueue_scripts', 'enqueue_non_critical_js' );
  • Use wwo_configuration hook to update web worker configurations.

    function update_wwo_config( $config ) {
      $config["debug"] = true;
      return $config;
    }
    add_filter( 'wwo_configuration', 'update_wwo_config' );
@thelovekesh thelovekesh added no milestone PRs that do not have a defined milestone for release [Type] Plugin Proposal A new plugin proposal labels May 24, 2024
@thelovekesh
Copy link
Member Author

@westonruter @adamsilverstein I have converted this into a standalone plugin. Next, I'll add a settings page to opt-in offloading for scripts listed in the Partytown documentation (https://partytown.builder.io/common-services). This way, the WordPress plugin team won't classify it as a "framework" plugin, as @westonruter previously mentioned.

@thelovekesh thelovekesh marked this pull request as ready for review June 24, 2024 15:58
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @alessandrocarrera, @erip2, @Chiflaos.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: alessandrocarrera, erip2, Chiflaos.

Co-authored-by: thelovekesh <thelovekesh@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>
Co-authored-by: eclarke1 <clarkeemily@git.wordpress.org>
Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: bethanylang <mxbclang@git.wordpress.org>
Co-authored-by: Mte90 <mte90@git.wordpress.org>
Co-authored-by: luisherranz <luisherranz@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no milestone PRs that do not have a defined milestone for release [Type] Plugin Proposal A new plugin proposal
2 participants