postcss-extract-media-query
postcss-extract-media-query copied to clipboard
Include more performance benefit info in the README
trafficstars
See #27
The code examples might be too opinionated perhaps, but I think they might be useful to show the HTML only approach vs the more dynamic approach.
Btw, You may not need loadCSS…, by Filament Group.
Another approach, without dependencies will be:
<script>
const media = window.matchMedia('(min-width: 1024px)')
if (media.matches) {
const desktopCSS = document.createElement('link');
desktopCSS.rel = 'stylesheet';
desktopCSS.href = '/css/desktop.css';
document.getElementsByTagName('head')[0].appendChild(desktopCSS);
}
</script>