DEV Community

Discussion on: How to create Javascript Scrollspy (Vanilla Js Tutorial)

Collapse
 
yellow1912 profile image
yellow1912

You should use the new observer api instead for better performance. If you use scroll event perhaps consider denouncing it?

Collapse
 
nikhilroy2 profile image
Nikhil Chandra Roy

hi, can you explain a little more what do you mean new observer api here?

Collapse
 
yellow1912 profile image
yellow1912

I mean this one:

developer.mozilla.org/en-US/docs/W...

It's a better way to detect when an element comes into view.