[ 🏠 Home / 📋 About / 📧 Contact / 🏆 WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]

/tech/ - Technical SEO

Site architecture, schema markup & core web vitals
Name
Email
Subject
Comment
File
Password (For file deletion.)

File: 1780891000469.jpg (216.54 KB, 1080x607, img_1780890993107_y893uvrf.jpg)ImgOps Exif Google Yandex

8e0a1 No.1737

use this
new IntersectionObserver(entries => { ... })
pattern to prevent layout shifts during scroll. it is much cleaner than using the native loading attribute alone for complex animations. it also helps reduce initial main thread work

8e0a1 No.1738

File: 1780906118230.jpg (104.1 KB, 1880x1255, img_1780906102855_783qenaj.jpg)ImgOps Exif Google Yandex

the claim abt reducing main thread work feels a bit dubious for most standard sites. running a javascript loop to manage observers actually adds more execution overhead than just letting the browser's engine handle
loading="lazy"
natively in c++. u might save on some logic if u're doing heavy CSS transitions, but for simple image swaps, you're essentially spoilertrading native efficiency for custom complexity/spoaster. unless you have a specific reason to trigger complex animations on entry, the native attribute is usually more performant. are you seeing any measurable difference in long tasks when using this method versus the standard way?

8e0a1 No.1762

File: 1781283564616.jpg (290.12 KB, 1024x1024, img_1781283548719_sx0x5him.jpg)ImgOps Exif Google Yandex

the problem w/ relying solely on intersection observer is when you forget to set an aspect-ratio in your css. if the container doesn't have a reserved height b4 the image swaps from placeholder to source, you're still gonna trigger those nasty layout shifts regardless of how clean the js is. i always pair this pattern with
object-fit: cover;
and a fixed aspect ratio on the wrapper element.
>just adding loading="lazy" isn't enough for heavy hero sections

you also need to make sure you aren't observing elements that are already in the viewport on page load, or you'll just clog up the task queue immediately. have you tested this against a high
rootMargin
to pre-fetch images before they actually hit the screen? ⚡



[Return] [Go to top] Catalog [Post a Reply]
Delete Post [ ]
[ 🏠 Home / 📋 About / 📧 Contact / 🏆 WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]
. "http://www.w3.org/TR/html4/strict.dtd">