Skip to content

Optimize CSS loaded with @StyleSheet #22472

@sissbruecker

Description

@sissbruecker

Describe your motivation

@StyleSheet currently just adds a link tag to the document head, but does no further optimization on the CSS. When building large applications that rely on a lot of custom styling, or include a custom base theme, this can result in several issues:

  • The CSS that needs to be loaded by the browser is not optimized for size
  • When splitting up stylesheets into multiple files for better organization and importing them from a main stylesheet with @import, this results in a "waterfall" of smaller requests which results in the app taking longer to render

Since @StyleSheet is intended to become the default solution for loading styles in v25 we should look in to improving this.

Describe the solution you'd like

The CSS loaded through @StyleSheet should be optimized for production:

  • The CSS should be minified to reduce the amount of data transferred to the browser
  • The CSS should be inlined so that nested imports do not result in separate requests to the server

In dev mode such an optimization is probably not necessary.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    🪵Product backlog

    Status

    Maybe

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions