loading...

Discussion on: Using Smart CSS to Time Your Wonderful Newsletter Popup

Collapse
rikschennink profile image
Rik Schennink Author

Thanks, Andrew!

While IntersectionObserver is a super nice API, it's not really in line with the purpose behind the article, which is doing this by feeding info to CSS using JavaScript and not controlling the hiding and showing of elements with JavaScript. Thereby completely separating CSS from JavaScript.

Collapse
link2twenty profile image
Andrew Bone

I see, my apologies πŸ™‚

Generally, I try to avoid listening on scroll because it can cause jank when scrolling (especially on mobile).

That being said, "premature optimization is the root of all evil" πŸ˜…

xkcd

Thread Thread
rikschennink profile image
Rik Schennink Author

It’s something to surely take into account, that said, the previous article outlines some of the performance improvements applied in the code.

Collapse
bhaibel profile image
Betsy Haibel

The two approaches seem compatible to me! If the intersection observer updated the body class with a data-last-landmark attribute, instead of a raw %, you could still reference off of that with CSS.

Thread Thread
rikschennink profile image
Rik Schennink Author

Interesting approach! That would certainly work I think.