#87756preload CSS (loadCSS)
Description
Since you integrated defer and async for “includeJS” so well i would like to see the same feature for “includeCSS”.
Somethink like the following:
includeCSS.file1 = /PATH/file.css
includeCSS.file1.preload = 1
Which generates a Link-Tag with rel=“preload”, an as=“style” and onload=“this.onload=null;this.rel=‘stylesheet’”, like suggested here https://github.com/filamentgroup/loadCSS
The usage of <link rel="preload"> is supported by around 75% of the browsers (https://caniuse.com/#feat=link-rel-preload) and is highly recommended by Google (PagespeedInsights/Lighthouse).
In my opinion this should be integrated for single files and for concatenated files.
Reviews 1
History 68
-
Georg Ringer changed priority
Must haveShould have 02/21/19, 08:25 -
Kim Christiansen commented 02/28/20, 14:12
-
Kim Christiansen commented 10/07/20, 15:57
In TYPO3 10 you could include the css on the filament group way like this in fluid:
<f:asset.css identifier="mycss" href="EXT:yourextension/path/to/css/mycss.css" media="print" additionalAttributes="{onload:'this.media=\'all\''}" /> -
Gerrit Code Review pushed patch set 1 for master to change 66073 status
NewUnder Review 10/07/20, 18:41 -
Marco H commented 04/01/21, 23:57
Kim Christiansen wrote in #note-3:
> In TYPO3 10 you could include the css on the filament group way like this in fluid:
>
> […]Doesn’t work with concatenation though, right?
-
Gerrit Code Review pushed patch set 2 for main to change 66073 11/29/21, 13:23
-
Benni Mack changed status
Under ReviewNew 11/09/26, 11:24 -
Georg Ringer commented and changed status
NewClosed 11/13/26, 19:07Thanks for the suggestion! Since this was filed in 2019, the options around CSS loading have changed quite a bit:
- Feature: #91499 added arbitrary additional tag attributes for
page.includeCSS,page.includeCSSLibsand the other include options. The “load CSS non-blocking” pattern described in the comments (media="print"with anonloadhandler) can be configured that way without a dedicatedpreloadoption. In Fluid the same is possible withf:asset.cssandadditionalAttributes. PageRenderer::addCssFile()andaddCssLibrary()take therelvalue as a parameter, so arel="preload"link together with the matchingasattribute is not tied to a special core option either.- The frontend asset concatenation and compression, which the request also wanted to cover, was removed in v14 (Breaking: #108055). Integrators who need it use a build step or an extension.
As the original request, a dedicated
preloadoption forincludeCSS, is covered by these building blocks and has not been picked up since 2019 (the only change was abandoned in 2021), I’m closing this issue to keep the tracker focused.If something is still missing in your setup, for example a documented way to emit
rel="preload"together with the matchingasattribute, please feel free to open a new, focused issue with the configuration you tried. Thanks again for the idea! - Feature: #91499 added arbitrary additional tag attributes for
The filament group recommends a new implementation:
https://www.filamentgroup.com/lab/load-css-simpler/
So could it be possible to add the onload attribute instead?