CSS render as internal or external

Created on 8 September 2023, 10 months ago
Updated 11 September 2023, 10 months ago

Was curious if you could allow the rendered CSS to be an external file when a certain size is reached. Currently, everything is inlined, which is great for smaller output, but for a large output, I think an external file would be more performant.

✨ Feature request
Status

Closed: works as designed

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @badg0003
  • Status changed to Closed: works as designed 10 months ago
  • πŸ‡¦πŸ‡ΉAustria hudri Austria

    There are currenly no plans to implement this, beause it most likely will result in worse performance in most scenarios.

    The choice to include the CSS inline in HTML doc was intentional, mostly because the critical CSS path (things visible on screen before scrolling down) should always be inline in the doc. Making the CSS external would most likely result in worse performance.

    One major advantage of TailwindCSS is that it removes any unncecessary CSS. The major advantage of this module is that it delivers perfectly trimmed CSS per Drupal page. This also means that the external CSS file would is usually unique per page, and a performance gain from the re-usage of external CSS does not really exist. OTOH the delivered CSS also is usually quite small (it might look large to the human eye, but it is trimmed and repetitive, so zip compression will easily bring it down below the 14kB mentioned in the Google link above).

    The real key to performance is that Drupal's "Internal Page Cache" module is active and can return a cached response, because then it also returns fully cached Tailwind CSS, and it simply does not need an external cached CSS.

    OTOH registered users (incl. admin users) never hit the Internal Page Cache and always have to wait . I recommend to use this module only if you can reliably use the Interal Page Cache module == the overwhelming part of your audience is anonymous users.

Production build 0.69.0 2024