ember-component-css icon indicating copy to clipboard operation
ember-component-css copied to clipboard

Load CSS lazily / unload it after no longer used

Open ebryn opened this issue 10 years ago • 4 comments

We should have an option that allows the addon to dynamically require/load the CSS the first time a component is instantiated and potentially also unload it after every instance of it is removed. This will help prevent leakage and might even have some performance benefits?

ebryn avatar Apr 13 '15 01:04 ebryn

I'm all for lazy-loading things. Is the approach you're thinking about to inject the CSS into a style tag when the component is inserted and remove after it is destroyed?

trentmwillis avatar Apr 13 '15 03:04 trentmwillis

Really interesting idea. Do you know if anyone out there has done any research into the perf implications of an approach like this? I could imagine introducing new styling rules during render might have a negative impact, given that the browser will have to verify that they don't affect the rest of the existing DOM.

dfreeman avatar Apr 13 '15 15:04 dfreeman

Are there lifecycle hooks for adding/removing of components from the dom that can be used to dynamically load/unload stylesheets?

oligriffiths avatar Dec 01 '15 18:12 oligriffiths