Skip to content

Commit dcd5773

Browse files
authored
Avoid adding onload attribute to stylesheet when serving AMP response (#917)
1 parent fea550b commit dcd5773

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

includes/core.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,9 @@ function google_fonts_style_loader_tag( $tag, $handle, $href, $media ) {
507507
// Remove once core supports preload natively.
508508
$tag = "<link rel='preload' as='style' href='$href' />\n" . $tag;
509509

510-
$tag = str_replace( array( "media=\"$media\"", "media='$media'" ), 'media="print" onload="this.media=\'all\'"', $tag );
510+
if ( ! is_amp() ) {
511+
$tag = str_replace( array( "media=\"$media\"", "media='$media'" ), 'media="print" onload="this.media=\'all\'"', $tag );
512+
}
511513

512514
// phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
513515
$tag .= "\n<noscript><link rel=\"stylesheet\" href=\"$href\" /></noscript>";

0 commit comments

Comments
 (0)