amitmerchant1990 / amitmerchant-dot-com-comments

1 stars 0 forks source link

conditionally-loading-css-or-any-resource-using-media-queries/ #46

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Conditionally loading CSS or any resource using media queries — Amit Merchant — A blog on PHP, JavaScript, and more

Unless you’re using something like Tailwind CSS, the stylesheet files are one of the most expensive resources that your application is loading.

https://www.amitmerchant.com/conditionally-loading-css-or-any-resource-using-media-queries/

simevidas commented 2 years ago

Now, the resources will then only be loaded if the media condition is true.

I thought that all stylesheets are still loaded, but the ones whose media doesn’t match are just loaded with a lower priority. It might be worth testing this to confirm that it’s true.