ember-component-css
ember-component-css copied to clipboard
Load CSS lazily / unload it after no longer used
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?
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?
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.
Are there lifecycle hooks for adding/removing of components from the dom that can be used to dynamically load/unload stylesheets?