JavaScript · Middle · Question 45 of 75

What's the most convenient way to detect that an element entered the viewport?

Explanation

IntersectionObserver asynchronously reports when an element intersects the viewport, without loading the main thread on every scroll. Uses: lazy loading, infinite feeds, impression analytics. MutationObserver tracks DOM changes, not visibility.

Further reading

Problem with a question

JavaScript · Middle · question 45

Test yourself

Take the JavaScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz