Skip to content

Commit 5ae3ed2

Browse files
committed
Skip needlessly adding Bento styles to AMP pages
1 parent 427ffdf commit 5ae3ed2

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

includes/amp-helper-functions.php

+2
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,8 @@ function amp_register_default_styles( WP_Styles $styles ) {
999999
);
10001000
$styles->add_data( 'amp-icons', 'rtl', 'replace' );
10011001

1002+
// These are registered exclusively for used for non-AMP pages that manually enqueue them. They aren't needed on
1003+
// AMP pages due to the runtime style being present and because the styles are inlined in the scripts already.
10021004
if ( amp_is_bento_enabled() ) {
10031005
foreach ( AMP_Allowed_Tags_Generated::get_extension_specs() as $extension_name => $extension_spec ) {
10041006
if ( empty( $extension_spec['bento']['has_css'] ) ) {

includes/class-amp-theme-support.php

-19
Original file line numberDiff line numberDiff line change
@@ -1561,25 +1561,6 @@ public static function ensure_required_markup( Document $dom, $script_handles =
15611561
}
15621562
$links[ Attribute::REL_PRELOAD ] = array_merge( $prioritized_preloads, $links[ Attribute::REL_PRELOAD ] );
15631563

1564-
// Add stylesheets for Bento components.
1565-
if ( amp_is_bento_enabled() ) {
1566-
foreach ( array_keys( $amp_scripts ) as $amp_script ) {
1567-
if ( ! wp_style_is( $amp_script, 'registered' ) ) {
1568-
continue;
1569-
}
1570-
$links[ Attribute::REL_STYLESHEET ][] = AMP_DOM_Utils::create_node(
1571-
$dom,
1572-
Tag::LINK,
1573-
[
1574-
Attribute::REL => Attribute::REL_STYLESHEET,
1575-
Attribute::TYPE => 'text/css',
1576-
Attribute::HREF => wp_styles()->registered[ $amp_script ]->src,
1577-
'data-ampdevmode' => '',
1578-
]
1579-
);
1580-
}
1581-
}
1582-
15831564
/*
15841565
* "4. Use preconnect to speedup the connection to other origin where the full resource URL is not known ahead of time,
15851566
* for example, when using Google Fonts."

0 commit comments

Comments
 (0)