Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9eb5041
Remove support for IE conditional scripts and styles
joedolson Aug 15, 2025
caf0887
Update scripts.php
joedolson Aug 15, 2025
1bd20ae
Update tests to expect empty results for conditional scripts and thei…
joedolson Aug 18, 2025
e4d1717
Update conditional inline styles test
joedolson Aug 18, 2025
5fb72b7
Unset dependencies for conditional scripts.
joedolson Aug 18, 2025
22fe20c
Restore concat_and_core_dependency test
joedolson Aug 19, 2025
f2011cd
Remove ticket ref
joedolson Aug 19, 2025
f4b1ccb
Update src/wp-includes/class-wp-scripts.php
joedolson Aug 21, 2025
69b243a
Update src/wp-includes/class-wp-styles.php
joedolson Aug 21, 2025
b0cfbc8
Update tests/phpunit/tests/dependencies/scripts.php
joedolson Aug 21, 2025
9d5da03
Update tests/phpunit/tests/dependencies/scripts.php
joedolson Aug 21, 2025
141b5bc
Move dependency exits earlier per suggestion
joedolson Aug 21, 2025
0df6ba1
Code style
joedolson Aug 22, 2025
64f11e1
Fix test_wp_script_add_data_with_conditional_key
joedolson Aug 22, 2025
ede759b
Remove space
joedolson Sep 1, 2025
3834934
Add comment about removal of conditional dependencies
joedolson Sep 1, 2025
1b5181a
Add a deprecated argument for conditional keys
joedolson Sep 1, 2025
d083a48
Add expect deprecation to tests.
joedolson Sep 1, 2025
ab365f1
expectDeprecation is not the appropriate method.
joedolson Sep 4, 2025
63dd8a7
Remove translator comment; this string does not require arguments.
joedolson Sep 4, 2025
21934fd
Update src/wp-includes/class-wp-styles.php
joedolson Sep 4, 2025
bf35196
Update class-wp-styles.php
joedolson Sep 4, 2025
35e7fae
Merge branch 'trunk' into remove-ie-conditionals
joedolson Sep 4, 2025
bcc8917
Remove that.
joedolson Sep 4, 2025
cae85c8
Add @expectedDeprecated annotation to tests
sirreal Sep 5, 2025
7e91911
Update deprecation notice text
joedolson Sep 29, 2025
9541e3c
Restore json2.js, register with backward compatibility comment.
joedolson Sep 29, 2025
73d0913
Merge branch 'trunk' into remove-ie-conditionals
joedolson Sep 29, 2025
56682c3
Remove extra empty line
sirreal Oct 2, 2025
681b3b6
Add bypass mechanism for doing it wrong
sirreal Oct 2, 2025
e302164
Merge branch 'trunk' into remove-ie-conditionals
joedolson Oct 2, 2025
104c076
Empty json2
joedolson Oct 2, 2025
14c196b
Restore empty wp-embed-template-ie.css and enqueue with exempted cond…
joedolson Oct 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
520 changes: 1 addition & 519 deletions src/js/_enqueues/vendor/json2.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/wp-includes/class-wp-dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,13 @@ public function add_data( $handle, $key, $value ) {
if ( ! isset( $this->registered[ $handle ] ) ) {
return false;
}
if ( 'conditional' === $key && '_required-conditional-dependency_' !== $value ) {
_deprecated_argument(
'WP_Dependencies->add_data()',
'6.9.0',
__( 'IE conditional comments are ignored by all supported browsers.' )
);
}

return $this->registered[ $handle ]->add_data( $key, $value );
}
Expand Down
40 changes: 15 additions & 25 deletions src/wp-includes/class-wp-scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ public function do_item( $handle, $group = false ) {
}

$obj = $this->registered[ $handle ];
if ( $obj->extra['conditional'] ?? false ) {
return false;
}

if ( null === $obj->ver ) {
$ver = '';
Expand All @@ -303,12 +306,9 @@ public function do_item( $handle, $group = false ) {
$ver = $ver ? $ver . '&' . $this->args[ $handle ] : $this->args[ $handle ];
}

$src = $obj->src;
$strategy = $this->get_eligible_loading_strategy( $handle );
$intended_strategy = (string) $this->get_data( $handle, 'strategy' );
$ie_conditional_prefix = '';
$ie_conditional_suffix = '';
$conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : '';
$src = $obj->src;
$strategy = $this->get_eligible_loading_strategy( $handle );
$intended_strategy = (string) $this->get_data( $handle, 'strategy' );

if ( ! $this->is_delayed_strategy( $intended_strategy ) ) {
$intended_strategy = '';
Expand All @@ -333,16 +333,11 @@ public function do_item( $handle, $group = false ) {
return false;
}

if ( $conditional ) {
$ie_conditional_prefix = "<!--[if {$conditional}]>\n";
$ie_conditional_suffix = "<![endif]-->\n";
}

$before_script = $this->get_inline_script_tag( $handle, 'before' );
$after_script = $this->get_inline_script_tag( $handle, 'after' );

if ( $before_script || $after_script ) {
$inline_script_tag = $ie_conditional_prefix . $before_script . $after_script . $ie_conditional_suffix;
$inline_script_tag = $before_script . $after_script;
} else {
$inline_script_tag = '';
}
Expand Down Expand Up @@ -378,7 +373,7 @@ public function do_item( $handle, $group = false ) {
// Have to print the so-far concatenated scripts right away to maintain the right order.
_print_scripts();
$this->reset();
} elseif ( $this->in_default_dir( $filtered_src ) && ! $conditional ) {
} elseif ( $this->in_default_dir( $filtered_src ) ) {
$this->print_code .= $this->print_extra_script( $handle, false );
$this->concat .= "$handle,";
$this->concat_version .= "$handle$ver";
Expand All @@ -389,18 +384,8 @@ public function do_item( $handle, $group = false ) {
}
}

$has_conditional_data = $conditional && $this->get_data( $handle, 'data' );

if ( $has_conditional_data ) {
echo $ie_conditional_prefix;
}

$this->print_extra_script( $handle );

if ( $has_conditional_data ) {
echo $ie_conditional_suffix;
}

// A single item may alias a set of items, by having dependencies, but no source.
if ( ! $src ) {
if ( $inline_script_tag ) {
Expand Down Expand Up @@ -442,9 +427,9 @@ public function do_item( $handle, $group = false ) {
if ( isset( $obj->extra['fetchpriority'] ) && 'auto' !== $obj->extra['fetchpriority'] && $this->is_valid_fetchpriority( $obj->extra['fetchpriority'] ) ) {
$attr['fetchpriority'] = $obj->extra['fetchpriority'];
}
$tag = $translations . $ie_conditional_prefix . $before_script;
$tag = $translations . $before_script;
$tag .= wp_get_script_tag( $attr );
$tag .= $after_script . $ie_conditional_suffix;
$tag .= $after_script;

/**
* Filters the HTML script tag of an enqueued script.
Expand Down Expand Up @@ -836,6 +821,11 @@ public function add_data( $handle, $key, $value ) {
return false;
}

if ( 'conditional' === $key ) {
// If a dependency is declared by a conditional script, remove it.
$this->registered[ $handle ]->deps = array();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should only be the case if the conditional script is the only dependency pulling it in, right?

or at this point in the code will that be handled because the deps here are only for the condition script itself and not all scripts?

Copy link
Member

@sirreal sirreal Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are details here: #9497 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each script that has a dependency enqueues its dependencies separately; so any dependency will still be enqueued by other scripts.


if ( 'strategy' === $key ) {
if ( ! empty( $value ) && ! $this->is_delayed_strategy( $value ) ) {
_doing_it_wrong(
Expand Down
42 changes: 27 additions & 15 deletions src/wp-includes/class-wp-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ public function do_item( $handle, $group = false ) {
}

$obj = $this->registered[ $handle ];
if ( $obj->extra['conditional'] ?? false ) {

return false;
}
if ( null === $obj->ver ) {
$ver = '';
} else {
Expand All @@ -165,16 +168,7 @@ public function do_item( $handle, $group = false ) {
$ver = $ver ? $ver . '&amp;' . $this->args[ $handle ] : $this->args[ $handle ];
}

$src = $obj->src;
$ie_conditional_prefix = '';
$ie_conditional_suffix = '';
$conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : '';

if ( $conditional ) {
$ie_conditional_prefix = "<!--[if {$conditional}]>\n";
$ie_conditional_suffix = "<![endif]-->\n";
}

$src = $obj->src;
$inline_style = $this->print_inline_style( $handle, false );

if ( $inline_style ) {
Expand All @@ -189,7 +183,7 @@ public function do_item( $handle, $group = false ) {
}

if ( $this->do_concat ) {
if ( $this->in_default_dir( $src ) && ! $conditional && ! isset( $obj->extra['alt'] ) ) {
if ( $this->in_default_dir( $src ) && ! isset( $obj->extra['alt'] ) ) {
$this->concat .= "$handle,";
$this->concat_version .= "$handle$ver";

Expand Down Expand Up @@ -279,17 +273,13 @@ public function do_item( $handle, $group = false ) {
}

if ( $this->do_concat ) {
$this->print_html .= $ie_conditional_prefix;
$this->print_html .= $tag;
if ( $inline_style_tag ) {
$this->print_html .= $inline_style_tag;
}
$this->print_html .= $ie_conditional_suffix;
} else {
echo $ie_conditional_prefix;
echo $tag;
$this->print_inline_style( $handle );
echo $ie_conditional_suffix;
}

return true;
Expand Down Expand Up @@ -360,6 +350,28 @@ public function print_inline_style( $handle, $display = true ) {
return true;
}

/**
* Overrides the add_data method from WP_Dependencies, to allow unsetting dependencies for conditional styles.
*
* @since 6.9.0
*
* @param string $handle Name of the item. Should be unique.
* @param string $key The data key.
* @param mixed $value The data value.
* @return bool True on success, false on failure.
*/
public function add_data( $handle, $key, $value ) {
if ( ! isset( $this->registered[ $handle ] ) ) {
return false;
}

if ( 'conditional' === $key ) {
$this->registered[ $handle ]->deps = array();
}

return parent::add_data( $handle, $key, $value );
}

/**
* Determines style dependencies.
*
Expand Down
20 changes: 1 addition & 19 deletions src/wp-includes/css/wp-embed-template-ie.css
Original file line number Diff line number Diff line change
@@ -1,19 +1 @@
.dashicons-no {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we not leave this in as an empty file? or with a CSS comment that it’s deprecated?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of keeping the file with only a CSS comment inside. To maintain the handle too, you could define false for the source and move the line(s) to the "Deprecated CSS" section of script-loader.php.

	$styles->add( 'wp-embed-template-ie', false );
	$styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' );

The chance of someone labeling the embed IE stylesheet as a dependency is very low, but possible.

background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAQAAAAngNWGAAAAcElEQVR4AdXRVxmEMBAGwJMQCUhAIhKQECmRsFJwMFfp7HfP/E8pk0173CuKpt/0R+WaBaaZqogLagBMuh+DdoKbyRCwqZ/SnM0R5oQuZ2UHS8Z6k23qPxZCTrV5UlHMi8bsfHVXP7K/GXZHaTO7S54CWLdHlN2YIwAAAABJRU5ErkJggg==);
}

.dashicons-admin-comments {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAATUlEQVR4AWMYWqCpvUcAiA8A8X9iMFStAD4DG0AKScQNVDZw1MBRAwvIMLCA5jmFlCD4AMQGlOTtBgoNwzQQ3TCKDaTcMMxYN2AYVgAAYPKsEBxN0PIAAAAASUVORK5CYII=);
}

.wp-embed-comments a:hover .dashicons-admin-comments {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAATElEQVR4AWMYYqB4lQAQHwDi/8RgqFoBfAY2gBSSiBuobOCogaMGFpBhYAEdcwrhIPgAxAaU5O0GCg3DNBDdMIoNpNwwzFg3YBhWAABG71qAFYcFqgAAAABJRU5ErkJggg==);
}

.dashicons-share {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAc0lEQVR4AWMYfqCpvccAiBcA8X8gfgDEBZQaeAFkGBoOoMR1/7HgDeQa2ECZgQiDHID4AMwAor0MCmBoQP+HBnwAskFQdgBRkQJViGk7wiAHUr21AYdhDTA1dDOQHl6mPFLokmwoT9j0z3qUFw70L77oDwAiuzCIub1XpQAAAABJRU5ErkJggg==);
}

.wp-embed-share-dialog-open:hover .dashicons-share {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAc0lEQVR4AWMYhqB4lQEQLwDi/0D8AIgLKDXwAsgwNBxAiev+Y8EbyDWwgTIDEQY5APEBmAFEexkUwNCA/g8N+ABkg6DsAKIiBaoQ03aEQQ6kemsDDsMaYEroZiA9vEx5pNAl2VCesOmf9SgvHOhffNEfAAAMqPR5IEZH5wAAAABJRU5ErkJggg==);
}
/* Deprecated in WordPress 6.9 */
1 change: 0 additions & 1 deletion src/wp-includes/embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,6 @@ function wp_embed_excerpt_attachment( $content ) {
* @since 4.4.0
*/
function enqueue_embed_scripts() {
wp_enqueue_style( 'wp-embed-template-ie' );

/**
* Fires when scripts and styles are enqueued for the embed iframe.
Expand Down
3 changes: 2 additions & 1 deletion src/wp-includes/functions.wp-scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,10 @@ function wp_script_is( $handle, $status = 'enqueued' ) {
* Works only if the script has already been registered.
*
* Possible values for $key and $value:
* 'conditional' string Comments for IE 6, lte IE 7, etc.
* 'strategy' string 'defer' or 'async'.
*
* @since 4.2.0
* @since 6.9.0 Updated possible values to remove reference to 'conditional' and add 'strategy'.
*
* @see WP_Dependencies::add_data()
*
Expand Down
5 changes: 3 additions & 2 deletions src/wp-includes/functions.wp-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ function wp_style_is( $handle, $status = 'enqueued' ) {
* Works only if the stylesheet has already been registered.
*
* Possible values for $key and $value:
* 'conditional' string Comments for IE 6, lte IE 7 etc.
* 'rtl' bool|string To declare an RTL stylesheet.
* 'suffix' string Optional suffix, used in combination with RTL.
* 'alt' bool For rel="alternate stylesheet".
Expand All @@ -233,10 +232,12 @@ function wp_style_is( $handle, $status = 'enqueued' ) {
* @since 3.6.0
* @since 5.8.0 Added 'path' as an official value for $key.
* See {@see wp_maybe_inline_styles()}.
* @since 6.9.0 'conditional' value changed. If the 'conditional' parameter is present
* the stylesheet will be ignored.
*
* @param string $handle Name of the stylesheet.
* @param string $key Name of data point for which we're storing a value.
* Accepts 'conditional', 'rtl' and 'suffix', 'alt', 'title' and 'path'.
* Accepts 'rtl' and 'suffix', 'alt', 'title' and 'path'.
* @param mixed $value String containing the CSS data to be added.
* @return bool True on success, false on failure.
*/
Expand Down
15 changes: 8 additions & 7 deletions src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ function wp_default_scripts( $scripts ) {
$scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'clipboard', 'jquery', 'plupload', 'underscore', 'wp-a11y', 'wp-i18n' ) );
did_action( 'init' ) && $scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n );

$scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'json2', 'media-models' ), false, 1 );
$scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'media-models' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n );

$scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", array(), false, 1 );
Expand All @@ -1052,8 +1052,9 @@ function wp_default_scripts( $scripts ) {
$scripts->add_data( 'comment-reply', 'fetchpriority', 'low' ); // In Chrome this is automatically low due to the async strategy, but in Firefox and Safari the priority is normal/medium.
}

// Not used in core, obsolete. Registered for backward compatibility.
$scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2015-05-03' );
did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', 'lt IE 8' );
did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', '_required-conditional-dependency_' );

$scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.13.7', 1 );
$scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore', 'jquery' ), '1.6.0', 1 );
Expand Down Expand Up @@ -1284,7 +1285,7 @@ function wp_default_scripts( $scripts ) {
// JS-only version of hoverintent (no dependencies).
$scripts->add( 'hoverintent-js', '/wp-includes/js/hoverintent-js.min.js', array(), '2.2.1', 1 );

$scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2', 'underscore' ), false, 1 );
$scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'underscore' ), false, 1 );
$scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 );
$scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'wp-a11y', 'customize-base' ), false, 1 );
$scripts->add( 'customize-models', '/wp-includes/js/customize-models.js', array( 'underscore', 'backbone' ), false, 1 );
Expand Down Expand Up @@ -1504,7 +1505,7 @@ function wp_default_scripts( $scripts ) {
$scripts->add( 'media', "/wp-admin/js/media$suffix.js", array( 'jquery', 'clipboard', 'wp-i18n', 'wp-a11y' ), false, 1 );
$scripts->set_translations( 'media' );

$scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'jquery-ui-core', 'json2', 'imgareaselect', 'wp-a11y' ), false, 1 );
$scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array( 'jquery', 'jquery-ui-core', 'imgareaselect', 'wp-a11y' ), false, 1 );
$scripts->set_translations( 'image-edit' );

$scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), false, 1 );
Expand All @@ -1514,7 +1515,7 @@ function wp_default_scripts( $scripts ) {
* Navigation Menus: Adding underscore as a dependency to utilize _.debounce
* see https://core.trac.wordpress.org/ticket/42321
*/
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox', 'json2', 'underscore' ) );
$scripts->add( 'nav-menu', "/wp-admin/js/nav-menu$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'wp-lists', 'postbox', 'underscore' ) );
$scripts->set_translations( 'nav-menu' );

$scripts->add( 'custom-header', '/wp-admin/js/custom-header.js', array( 'jquery-masonry' ), false, 1 );
Expand Down Expand Up @@ -1646,9 +1647,7 @@ function wp_default_styles( $styles ) {
$styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons', 'dashicons', 'wp-mediaelement' ) );
$styles->add( 'wp-pointer', "/wp-includes/css/wp-pointer$suffix.css", array( 'dashicons' ) );
$styles->add( 'customize-preview', "/wp-includes/css/customize-preview$suffix.css", array( 'dashicons' ) );
$styles->add( 'wp-embed-template-ie', "/wp-includes/css/wp-embed-template-ie$suffix.css" );
$styles->add( 'wp-empty-template-alert', "/wp-includes/css/wp-empty-template-alert$suffix.css" );
$styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' );

// External libraries and friends.
$styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' );
Expand All @@ -1664,6 +1663,8 @@ function wp_default_styles( $styles ) {
$styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.css', array(), '0.9.15' );
$styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); // Old handle.
$styles->add( 'open-sans', $open_sans_font_url ); // No longer used in core as of 4.6.
$styles->add( 'wp-embed-template-ie', false );
$styles->add_data( 'wp-embed-template-ie', 'conditional', '_required-conditional-dependency_' );

// Noto Serif is no longer used by core, but may be relied upon by themes and plugins.
$fonts_url = '';
Expand Down
Loading
Loading