Skip to content

Commit

Permalink
Script Loader: stop enqueueing some now obsolete polyfills.
Browse files Browse the repository at this point in the history
Stop enqueueing polyfills such as `wp-polyfill-inert` (for the `inert` attribute) and `regenerator-runtime` (for generator functions), as they are no longer needed, considering the WordPress project's [https://make.wordpress.org/core/handbook/best-practices/browser-support/ browser support policy].

In addition to that, `wp-polyfill` (essentially `core-js`) is no longer enqueued as a dependency of `react`. This was added in [43903] to ensure compatibility with IE 11, which is no longer supported by WordPress. Developers requiring `wp-polyfill` need to manually add it as a dependency for their scripts.

Props swissspidy, flixos90, adamsilverstein, youknowriad, gziolo.
Fixes #60962.

git-svn-id: https://develop.svn.wordpress.org/trunk@57981 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
swissspidy committed Apr 10, 2024
1 parent 5afdac7 commit f525e66
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ function wp_default_packages_vendor( $scripts ) {
$suffix = wp_scripts_get_suffix();

$vendor_scripts = array(
'react' => array( 'wp-polyfill' ),
'react-dom' => array( 'react' ),
'react',
'react-dom' => array( 'react' ),
'regenerator-runtime',
'moment',
'lodash',
Expand All @@ -103,7 +103,7 @@ function wp_default_packages_vendor( $scripts ) {
'wp-polyfill-element-closest',
'wp-polyfill-object-fit',
'wp-polyfill-inert',
'wp-polyfill' => array( 'wp-polyfill-inert', 'regenerator-runtime' ),
'wp-polyfill',
);

$vendor_scripts_versions = array(
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/dependencies/scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,7 @@ public function test_wp_add_inline_script_before_after_concat_with_core_dependen
$wp_scripts->base_url = '';
$wp_scripts->do_concat = true;

$expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5Bchunk_0%5D=jquery-core,jquery-migrate,wp-polyfill-inert,regenerator-runtime,wp-polyfill,wp-dom-ready,wp-hooks&amp;ver={$wp_version}'></script>\n";
$expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5Bchunk_0%5D=jquery-core,jquery-migrate,wp-polyfill,wp-dom-ready,wp-hooks&amp;ver={$wp_version}'></script>\n";
$expected .= "<script type='text/javascript' id='test-example-js-before'>\nconsole.log(\"before\");\n</script>\n";
$expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
$expected .= "<script type='text/javascript' src='/wp-includes/js/dist/i18n.min.js' id='wp-i18n-js'></script>\n";
Expand Down

0 comments on commit f525e66

Please sign in to comment.