Responsive design allows webpages to adapt to different screen sizes and devices by using fluid widths, images, and CSS media queries. It began in 2010 with a combination of flexible layouts, media queries, and using the viewport to optimize content for varied screens. While responsive design improves the user experience across devices, developers must address challenges like conditionally loading appropriate images, scripts, and styles to avoid delivering unnecessary content.
20. The CSS3 Flexible Box, or flexbox, is a
layout mode providing for the
arrangement of elements on a page
such that the elements behave
predictably when the page layout must
accommodate different screen sizes
and different display devices.
MDN: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes
51. <script data-mq="(min-width: 640px)"
data-src=/slideshow/what-is-responsive-and-do-i-need-it/49127120/"/ads.com/banner.js"></script>
<script data-mq="(min-width: 640px)"
data-src="livechat.js" ></script>
<script>
var scripts = document.getElementsByTagName("script");
for(var i=0;i<scripts.length; i++) {
// Test if the Media Query matches
var mq = scripts[i].getAttribute("data-mq");
if (mq && window.matchMedia(mq).matches) {
// If so, append the new (async) element.
var s = document.createElement("script");
s.type = 'text/javascript';
s.src = scripts[i].getAttribute("data-src");
document.body.appendChild(s);
}
}
</script>
Better
Conditional loading?
https://www.safaribooksonline.com/library/view/responsive-fast/9781491912935/ch04.html
73. 1. Get a DDR
2. Write Server-Side Code using
DDR (e.g. conditional loading
etc.)
3. Enhance rendered HTML on
Client-Side
RESS
In a nutshell
74. 1. Get a DDR
2. Detect features on Client-
Side
3. Write Server-Side Code using
DDR (e.g. conditional loading
etc.)
4. Set Cookies, reload.
RESS
In a nutshell
75. Websites should be loaded FAST
Websites should have a nice UX
Content should be optimized!
Content should be meaningful!
Why such a hassle?