Windows
Windows
Microsoft and Google have collaborated to bring support for CSS module scripts to Chromium, and they will be available starting in Microsoft Edge and Chrome version 93. The new feature can be used to load CSS style sheets with
import sheet from './styles.css' assert { type: 'css' };
document.adoptedStyleSheets = [sheet];
shadowRoot.adoptedStyleSheets = [sheet];
Loading a stylesheet without needing to create a
import
statements just like . The imported sheets are that can be directly applied to documents or like this: import sheet from './styles.css' assert { type: 'css' };
document.adoptedStyleSheets = [sheet];
shadowRoot.adoptedStyleSheets = [sheet];
Loading a stylesheet without needing to create a
style
or link
element can be more convenient and even than other ways of importing and applying CSS from JavaScript. CSS module scripts will be available starting in Microsoft Edge and Chrome version 93. Read more about the feature over at web.dev: