3 ms·
I remember how it was good practice to assign width and height to <img> tags. The idea being the browser would know how to render the things around the picture
by Dalewyn 4y ago
I remember how it was good practice to assign width and height to <img> tags.
The idea being the browser would know how to render the things around the picture without needing to download the picture first, preventing the page from jumping around as the quicker and lighter HTML was downloaded and rendered first.
- chrisweekly 4y agoThat still is a best practice. That "jumping around" is now referred to as "CLS" -- Cumulative Layout Shift -- one of the "Core Web Vitals" metrics used to quantify performance-related UX.
- teknopaul 4y agoI sometmes like CLS, it makes it look like things are happening instead of feeling like a wait time. I recently used a simple templating mechanism elem = jquery.clone() ... elem.slideDown() And this renders bits of the page moving them as it does it; slideDown() is in jquery core. It used to be popular before that biz of rendering grey squares first got invented
- tryfinally 4y agoLayout shift feels fairly terrible when you're navigating to an element that is at the bottom of the page (via #id) or simply refreshing the page. There is literally nothing more annoying than clicking the wrong link because the layout shifted under the cursor at just the wrong moment. CLS is also known as "jank" for a reason.
- christophilus 4y agoI use aspect ratio for this now that it's supported in CSS. It might be my favorite CSS feature since flex.