I'm trying to find out how to render different critical css or load different stylesheets based on the viewport/device. This might be a dublicate question, but everywhere I look, the given answer seems to bee "Use media queries". But this doesn't solve the issue i'm trying to fix.
My main issue is with performance and user metrics. I want to optimize the amout of css that's being loaded. Now i've noticed some sites don't scale up/down when changing the viewport size because they only load the css for the viewport size on load. (I've noticed that the 'mobile' stylesheets are loaded when using responsive inspector mode, which leads me to think it's not the viewport size but most likely the device type or something like that)
An example of this is used by Google. For example their doodles page loads mobilestyles.css
when loaded in responsive mode and styles.css
when loaded on regular size:
HTML head when loaded regular view
HTML head when loaded responsive view
This doesn't seem to be dynamically altered after load with javascript in any way. How does the served html change based on the device making the request and is it possible to use this to serve/render a different <style>
tag for viewport specific critical css?