|
|
|
|
|
by cj
1322 days ago
|
|
How would CDNs cache both a mobile optimized and desktop optimized version of a site on the edge? I suppose this can still (kind of) be done, but on the client-side using the viewport size (combined with javascript or CSS @media) rather than on the backend. |
|
HTML is responsive by default, just don't break this, and yes, you can use media queries if needed.
For images, we have srcset to tell the browser what to download depending on the screen size [1]. You should not try to optimize the bandwidth if I'm on mobile. I might be on a Wi-Fi connection with a mobile or with my tethered mobile connection on my laptop. Just optimize for everything anyway.
The backend should not be involved in how the site is presented, and the CDN should be as dumb as possible, or should not be used at all.
For apps, you have Javascript to do whatever you want.
Mobile / desktop detection is yet another user agent detection in disguise anyway. Just detect my screen size, my dpi, my tactile screen, my mouse, possibly my bandwidth is it's really necessary (videoconferencing for instance). I could be using a mouse on a mobile device. Both the mouse and the touchscreen need to work. You might not need to do feature detection, just bind these events unconditionally. I could plug a secondary tactile screen and move my browser window on this screen.
Many devices are hybrid now. A tablet with a keyboard is not that weird today. What should isMobile return? "YesAndNo"?
I've not seen a really convincing use of isMobile yet. But I've seen harmful ones. They are full of assumptions that are correct most of the times, but still have exceptions.
[1] https://developer.mozilla.org/en-US/docs/Web/HTML/Element/so...