Chrome 73 shipped with support for constructable stylesheets which allow for the creation of distributable & reusable styles.
Their announcement reads:
It’s always been possible to create stylesheets using JavaScript. Create a element using
document.createElement('style')
. Then access its sheet property to obtain a reference to the underlyingCSSStyleSheet
instance, and set the style.Using this method tends to lead to style sheet bloat. Even worse, it causes a flash of unstyled content. Constructable Stylesheets make it possible to define and prepare shared CSS styles, and then apply those styles to multiple Shadow Roots or the Document easily and without duplication.
- Do constructable style sheets offer a noticeable improvement in performance (rendering time & memory consumption) vs updating the CSS of an element via JavaScript?
- Are there any performance benchmarks for constructable style sheets?