Question · JavaScript and TypeScript course · Module 5: Advanced JavaScript

Lazy Loading with IntersectionObserver

Why is IntersectionObserver better than listening to the scroll event for implementing lazy loading?

Answer options

  • The browser tracks visibility itself and calls the callback only when it changes, instead of a scroll handler invoked dozens of times per second
  • It only works in the latest browsers
  • It automatically compresses images
  • It does not require any JavaScript code

You can check the correct answer by solving this task in the CodeWorlds game.