Skip to content

Latest commit

 

History

History
37 lines (21 loc) · 1.15 KB

README.md

File metadata and controls

37 lines (21 loc) · 1.15 KB

Case study

Scroll with throttle

Description

While listening for scroll event, this event will be fired pretty often. If we have an expensive function which needs to be invoked every time, browser will shorty become very slow while rendering content. We can solve this issue by preventing calling expensive function so many times. In this case Lodash's function throttle is very handy.

Try out this case study.

By installing and serving up, you will see scrolling performance is very bad. If you enable throttling, performance will improve.

In js/main.js you can play with values:

a) time, currently set to 1000 ms

Expensive function (wrapped by throttle function) will be called only once in given time.

b) i, currently set to 1000

How many times expensive function will iterate and generate random number.

Install

npm install

Run

npm run serve

Open browser at http://localhost:8080

Resources