News for hackers. Stuff that matters.
Re:How we improved our website's performance by giantrobot on Sunday January 24, 2021 @04:11PM (#25896088)
That's why there's all kinds of helpful features in HTML/CSS like media queries. You can serve up raw content and let the device make decisions on what resources to use to display the content. You can tell the device the most optimal resources for its particular constraints.

As a for instance you your script tag can just include a bunch of @import statements. Thankfully @import statements support media queries [0]. So you get the utility of external style sheets but can load one optimized for the client device. Unlike media queries on link tags the browser doesn't load style sheets (well they're not supposed to) that don't match the media queries.

It's also trivial to include a tiny bit of base styling with every page in a script tag. It doesn't blow any size budgets and makes sure a page is readable even with no external assets.

[0] https://developer.mozilla.org/en-US/docs/Web/CSS/@import

There are no comments on this comment yet.