Lazy Loading Component Based CSS#1095
Open
Gnyblast wants to merge 3 commits intomaxence-charriere:masterfrom
Open
Lazy Loading Component Based CSS#1095Gnyblast wants to merge 3 commits intomaxence-charriere:masterfrom
Gnyblast wants to merge 3 commits intomaxence-charriere:masterfrom
Conversation
added 2 commits
November 1, 2025 13:51
- Created 2 new method for Composer so that LazyCSS file can be set and get - Created implementation for initial load done by server-side to load the component CSS into the head because when applied later it creates a bad UI experience like components are bareand then being styled after page load which is quite bad - Created client-side wasm implementation for Mount and Dismount so that components CSS on navigation can get lazy loaded or unloaded on exit
- I reduced down the work to a single iteration for checking If LazyCSS exists while going over childrens
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

I was looking for a way to lazy load/unload component based CSS on navigation.
This is an important and good future for various reasons:
I made it work on client-side and server-side initial rendering too and tested on my local.
http.goit goes over the Composer type of components deep down and checks if it has dedicated style file set, then on the initial creation ofheadtag, it adds them there (only once)OnMountComponentandOnDismountComponent(because only Composer type can have dedicated CSS) checks if dedicated CSS file is set and then adds it to head. Also there's a small implementation that waits css to be loaded to mount the component, otherwise it's again quite bad user experience happens, like component mount and css then applied to bare HTML. Also it removes them when you are navigating to another page which does not have anything to do with that CSS.Quick example:
So this is a bit forcing you to have constructor which I don't think it's bad, so that you can set your path for css dedicated to that components.
I believe same can be done for JS but I'm not sure about it since the users of this framework tries to avoid JS on their project. Regardless usage of such external libraries that are component based (such as material library) might require you to inject JS to your component with some lazy strategy.
I might for sure missed something or some of my implementation might be handled better because I'm not very familiar with code base, I'm open to suggestions.