In 2011, an issue popped up on Twitter's feed: when you scrolled down twitter's feed it became really slow and unresponsive.
Here's why...
It’s a very, very, bad idea to attach handlers to the window scroll event.
Why?
When you scroll through a trackpad, scrolling wheel, or drag the scrollbar, easily around 30 events per second are triggered. Moreover, when you slowly scroll on a smartphone, easily around 100 events per second are triggered.
Here's an experiment:
https://codesandbox.io/s/scroll-event-trigger-count-mqfr73?file=/src/index.js
These days there are slightly more sophisticated ways of handling events. Let me introduce you to Debounce and Throttle.
The debounce technique allows us to “group” multiple raised sequential functions into a single function.
Suppose you create a search bar and users can search using keywords in the search bar, and once the user is done you need to show suggestions.
If we tie the search API to the keystroke event, every time a keystroke happens API will be called leading to slow and unreliable performance.
With debounce,
the API will be called after Xms(in the about example 400ms) when the user stops keystrokes leading to a much faster and more reliable user experience.
Usecases:
By using throttling, we don’t allow our function to execute more than once every X milliseconds.
The main difference between this and debouncing is that throttle guarantees the execution of the function regularly, at least every X milliseconds.
Usecase:
Types of Rich Text Editors In the previous post I explained what are RTEs and why are they used, in this post, I am going to throw some light on the types of RTEs, and will make you familiar with the sample content format. https://fifo.im/p/35ghmd1uxln0
Rich Text Editor In recent years, the field of Content Creation and Representation on Digital platforms has seen massive disruption. This transition has shown how companies are racing to build the best experience for content creators in the enterprise domain and trying to find innovative ways to break the traditional molds of sharing and consuming content.