Issue Feature Closed

#87756preload CSS (loadCSS)

Andreas Lochner 02/21/19, 07:46 updated 11/13/26, 19:07

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

  1. Kim Christiansen commented <span data-processor="relativetime" data-value="2020-02-28T14:12:40+00:00" > 02/28/20, 14:12 </span>

    The filament group recommends a new implementation:

    <link rel="stylesheet" href="/path/to/my.css" media="print" onload="this.media='all'">

    https://www.filamentgroup.com/lab/load-css-simpler/

    So could it be possible to add the onload attribute instead?

    includeCSS.file1.onload = this.media='all'
  2. Kim Christiansen commented <span data-processor="relativetime" data-value="2020-10-07T15:57:02+00:00" > 10/07/20, 15:57 </span>

    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\''}" />
  3. Gerrit Code Review pushed patch set 1 for master to change 66073 status New Under Review <span data-processor="relativetime" data-value="2020-10-07T18:41:41+00:00" > 10/07/20, 18:41 </span>

  4. Marco H commented <span data-processor="relativetime" data-value="2021-04-01T23:57:07+00:00" > 04/01/21, 23:57 </span>

    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?

  5. Georg Ringer commented and changed status New Closed <span data-processor="relativetime" data-value="2026-11-13T19:07:36+00:00" > 11/13/26, 19:07 </span>

    Thanks 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.includeCSSLibs and the other include options. The “load CSS non-blocking” pattern described in the comments (media="print" with an onload handler) can be configured that way without a dedicated preload option. In Fluid the same is possible with f:asset.css and additionalAttributes.
    • PageRenderer::addCssFile() and addCssLibrary() take the rel value as a parameter, so a rel="preload" link together with the matching as attribute 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 preload option for includeCSS, 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 matching as attribute, please feel free to open a new, focused issue with the configuration you tried. Thanks again for the idea!