See support topic.
Given a site with the following HTML:
<link rel='stylesheet' id='companion-bundle-css' href="" data-href='http://example.com/style.css' type='text/css' media='all' />
This is showing up as an error:
Note that the audit currently is accounting for async CSS whereby the media is set to something other than screen or all:
|
} elseif ( 'LINK' === $tag ) { |
|
$rel = $processor->get_attribute( 'rel' ); |
|
if ( 'stylesheet' !== strtolower( (string) $rel ) ) { |
|
continue; |
|
} |
|
|
|
$media = $processor->get_attribute( 'media' ); |
|
if ( is_string( $media ) && 1 !== preg_match( '/^\s*(all|screen)\b/i', $media ) ) { |
|
continue; |
|
} |
|
|
|
$href = $processor->get_attribute( 'href' ); |
|
if ( ! is_string( $href ) ) { |
|
continue; |
|
} |
|
|
|
$size = perflab_aea_get_asset_size( $href ); |
|
$result['assets']['styles'][] = array( |
|
'src' => $href, |
|
'size' => is_wp_error( $size ) ? null : $size, |
|
'error' => is_wp_error( $size ) ? $size : null, |
|
); |
|
} |
Normally this is accompanied by an onload attribute on the LINK tag to rewrite the media to screen from something like print when the stylesheet has loaded.
We should also account for this case where the href is empty.
See support topic.
Given a site with the following HTML:
This is showing up as an error:
Note that the audit currently is accounting for async CSS whereby the
mediais set to something other thanscreenorall:performance/plugins/performance-lab/includes/site-health/audit-enqueued-assets/helper.php
Lines 110 to 132 in f7846e4
Normally this is accompanied by an
onloadattribute on theLINKtag to rewrite themediatoscreenfrom something likeprintwhen the stylesheet has loaded.We should also account for this case where the
hrefis empty.