Skip to content

Lazier CSS loading #2

@codewithkyle

Description

@codewithkyle

Currently the 'lazy' CSS is tied to the update() function call. Instead I think the CSS should only be loaded when the component is mounted and it should be a blocking process. We should not mount the component until after all the CSS requests have resolved. Developers would still be able to instantly invoke the lazy CSS loading functionality by using the css() function.

Why

The current functionality goes against the core principles of this library (in a way). We should only be loading the resources we need when we need them. The reason we loaded all the CSS upfront was to prevent styled content flashing. If we block the components mount behavior until all CSS requests have resolved we can avoid this unwanted side effect of lazy loading CSS.

Preserving backwards compatibility

This new behavior should sit behind a new config flag:

{
  lazierCSS: true
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions