SpinTheMic
Pro

Interview practice question

Detecting when an element becomes visible

Frontend Engineering · Async JavaScript and the Browser · Beginner

You want to trigger an animation or lazy-load content when an element enters the viewport. How do you do it efficiently?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • IntersectionObserver instead of scroll listeners.
  • Options: threshold, rootMargin.
  • Unobserve after triggering.
  • Native loading="lazy" for images.
  • Performance benefits.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics