Description
Preconditions (*)
- 2.3.4
Steps to reproduce (*)
- Enable
use_css_critical_path
Expected result (*)
- The stylesheets are only loaded once
Actual result (*)
styles-m.css
,styles-l.css
andprint.css
styles show up multiple times in developer tools.
I have traced the problem to the following method:
beforeSendResponse
in module-theme/Controller/Result/AsyncCssPlugin.php
This line appears to be re-inserting the original style tags:
$content = str_replace('</body', implode("\n", $cssMatches) . "\n</body", $content);
If you comment out this line, the HTML is as expected, with each style element existing only once and preventing double download of stylesheets.
I think there's some confusion over the implementation of the following technique:
<link rel="preload" as="style" media="all" onload="this.onload=null;this.rel='stylesheet'"href="...en_US/css/styles-m.css">
I would expect that the purpose of the onload method is that rather than needing one <link>
to preload and a separate <link>
at the bottom of the HTML to then achieve the affect of asynchronously loading the CSS, this behaviour can be achieved with just one <link>
element. After onload
event has fired, the rel
attribute swaps and applies the CSS.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status