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 76 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
6156b4a
Add partytown package in dependencies
thelovekesh Mar 27, 2022
6eb93f3
Add partytown scripts
thelovekesh Mar 27, 2022
ee95fda
Add web worker module under javascript scope
thelovekesh Mar 28, 2022
0b21107
Add tests for web worker module
thelovekesh Mar 28, 2022
d3c18b0
Update tests
thelovekesh Mar 28, 2022
c73faae
Update tests for Web Worker Module
thelovekesh Mar 28, 2022
96ff132
Update assert function for checking has_action
thelovekesh Apr 5, 2022
9fc418b
Fix package-lock file
thelovekesh Oct 13, 2022
90205c3
Add perflab_ prefix in functions and filters
thelovekesh Oct 13, 2022
f5f7738
Update in_array strict comparision to true
thelovekesh Oct 13, 2022
b62deaf
Fix grammar
thelovekesh Oct 13, 2022
868c538
Refactor code to get partytown scripts from single helper function
thelovekesh Oct 13, 2022
f7a7c66
Update module name
thelovekesh Oct 13, 2022
45c6dea
Add event forward array in partytown config
thelovekesh Oct 13, 2022
716f5e3
Remove partytown files
thelovekesh Oct 13, 2022
5bc2abd
Update directory name for more clarity about module
thelovekesh Oct 13, 2022
2202bc5
Add partytown lib path to gitignore
thelovekesh Oct 13, 2022
59fcc25
Update tests path for partytown module
thelovekesh Oct 13, 2022
30e77d5
Fix tests prefix and undefined method
thelovekesh Oct 13, 2022
8ef2483
Bump `@builder.io/partytown` from 0.5.1 to 0.5.4
thelovekesh Jan 20, 2024
3c6cf8e
Update closures to be static
thelovekesh Jan 20, 2024
6610d79
Add method visibility
thelovekesh Jan 20, 2024
419cd93
Update since annotation to use n.e.x.t format
thelovekesh Jan 20, 2024
a561c59
Add .vscode to ignored list
thelovekesh Jan 20, 2024
b4e2fe3
Update partytown config and script enqueuing
thelovekesh Jan 20, 2024
f1fc10c
Update partytown module test cases
thelovekesh Jan 20, 2024
87583a7
Update partytown module script handling
thelovekesh Jan 20, 2024
7950cb3
Bump `@builder.io/partytown` from 0.5.4 to 0.8.2
thelovekesh Jan 20, 2024
4ab5f9d
Add condition to load Partytown module based on ssl requirement
thelovekesh Jan 26, 2024
6642c06
Add errors in the admin notices for Partytown Module
thelovekesh Jan 26, 2024
372abbe
Add condition to exit early if module is accessed directly
thelovekesh Jan 26, 2024
636fb16
Remove file exists check for partytown library
thelovekesh Jan 26, 2024
59d817b
Add .eslintignore
thelovekesh Jan 26, 2024
d67aaa8
Remove pluggable functions from can-load.php file
thelovekesh Feb 3, 2024
624b850
Update module description
thelovekesh Feb 3, 2024
06f1030
Move Partytown Web Worker module to js-and-css focus area
thelovekesh Feb 3, 2024
a39f626
Add copy-webpack-plugin
thelovekesh Jan 26, 2024
45a8113
Bump @babel/traverse
thelovekesh Jan 26, 2024
287cf99
Update build command
thelovekesh Feb 3, 2024
ed95176
Update package-lock.json
thelovekesh Feb 3, 2024
4e7b66b
Update plugin path to remove any trailing slashes
thelovekesh Feb 3, 2024
64bf672
Update partytown tests path
thelovekesh Feb 3, 2024
c15ac74
Update partytown module tests cases
thelovekesh Feb 3, 2024
10aadf6
Update partytown module tests cases to reset wp scripts global state …
thelovekesh Feb 3, 2024
b8c11bb
Update substr offset to keep the logic clean
thelovekesh Feb 3, 2024
c3ab8fe
Add build assets steps in workflows
thelovekesh Feb 3, 2024
94b34e5
Bump @builder.io/partytown to 0.10.2
thelovekesh May 24, 2024
33393bc
Add 'web-worker-offloading' plugin to webpack configuration
thelovekesh May 24, 2024
d956227
Add build:plugin:web-worker-offloading script
thelovekesh May 24, 2024
0796e6b
Remove web-worker-offloading module files
thelovekesh May 24, 2024
b3dd573
Add web-worker-offloading
thelovekesh May 24, 2024
41eab36
Add web-worker-offloading plugin files
thelovekesh May 24, 2024
2068a6c
Add phpcs.xml.dist
thelovekesh May 24, 2024
7f441a6
Add web-worker-offloading
thelovekesh May 24, 2024
fb29731
Fix PHPStan errors
thelovekesh May 24, 2024
f932add
Add readme.txt
thelovekesh May 24, 2024
4d93d0a
Add config for web-worker-offloading
thelovekesh May 24, 2024
8f8a8e3
Add scripts for web-worker-offloading
thelovekesh May 24, 2024
447d13a
Fix partytown build files path
thelovekesh May 24, 2024
5e0bd31
Remove module test cases
thelovekesh May 24, 2024
2f82946
Update global with wp_scripts()
thelovekesh May 24, 2024
69dba1d
Add test cases for web-worker-offloading
thelovekesh May 24, 2024
d9ca229
Add return types; Remove redundant assertions
thelovekesh May 24, 2024
b8e1a2c
Revert empty line at EOF
thelovekesh May 24, 2024
3ca2c4f
Remove obselete modules path
thelovekesh May 24, 2024
68f5d3a
Remove redundant ignore paths
thelovekesh May 24, 2024
d8efc7e
Fix merge conflicts
thelovekesh May 31, 2024
a1218f8
Update package-lock.json
thelovekesh May 31, 2024
29bcd58
Update script offloading eligibility determining logic
thelovekesh May 31, 2024
edaa305
Update offloading script handle from partytown to web-worker-offloader
thelovekesh May 31, 2024
6208f18
Move web-worker-offloading testcase to plugins/web-worker-offloading/…
thelovekesh May 31, 2024
0705dd7
Add lint and test scripts for web-worker-offloading
thelovekesh May 31, 2024
782455e
Fix tests path for web-worker-offloading
thelovekesh May 31, 2024
ff7d759
Fix test cases after updates in web-worker-offloader plugin
thelovekesh May 31, 2024
427ca98
Merge branch 'trunk' into add/web-worker-offloading
thelovekesh Jun 24, 2024
e80da64
Merge branch 'trunk' into add/web-worker-offloading
thelovekesh Jul 8, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor code to get partytown scripts from single helper function
  • Loading branch information
thelovekesh committed May 31, 2024
commit 868c538680903f1b11212ee4d84509cf33f040c1
27 changes: 17 additions & 10 deletions modules/javascript/web-worker/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,7 @@ function perflab_web_worker_partytown_init() {
* @return void
*/
function perflab_web_worker_partytown_worker_scripts() {
global $wp_scripts;

$partytown_handles = array();

// Get all scripts which have a `partytown` dependency.
foreach ( $wp_scripts->registered as $handle => $script ) {
if ( ! empty( $script->deps ) && in_array( 'partytown', $script->deps, true ) ) {
$partytown_handles[] = $handle;
}
}
$partytown_handles = perflab_get_partytown_handles();

foreach ( $partytown_handles as $partytown_handle ) {
add_filter(
Expand Down Expand Up @@ -103,3 +94,19 @@ function( $tag, $handle, $src ) use ( $partytown_handle ) {
}
}
add_action( 'wp_print_scripts', 'perflab_web_worker_partytown_worker_scripts' );

/**
* Helper function to get all scripts tags which has `partytown` dependency.
*/
function perflab_get_partytown_handles() {
global $wp_scripts;

$partytown_handles = array();
foreach ( $wp_scripts->registered as $handle => $script ) {
if ( ! empty( $script->deps ) && in_array( 'partytown', $script->deps, true ) ) {
$partytown_handles[] = $handle;
}
}

return $partytown_handles;
}
18 changes: 1 addition & 17 deletions tests/modules/javascript/web-worker/web-worker-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function perflab_test_web_worker_partytown_worker_scripts() {

$this->assertEquals(
$script_handles,
$this->get_partytown_handles()
perflab_get_partytown_handles()
);

$expected_scripts_chunk = '';
Expand Down Expand Up @@ -136,20 +136,4 @@ function perflab_test_web_worker_partytown_worker_scripts() {
*/
$wp_scripts->done = array();
}

/**
* Helper function to get all scripts tags which has `partytown` dependency.
*/
function get_partytown_handles() {
global $wp_scripts;

$partytown_handles = array();
foreach ( $wp_scripts->registered as $handle => $script ) {
if ( ! empty( $script->deps ) && in_array( 'partytown', $script->deps, true ) ) {
$partytown_handles[] = $handle;
}
}

return $partytown_handles;
}
}