I have a basic question related to JavaScript.
The scenario is a user scrolling down a news feed of some social media app.
This would have three different processes occurring in-between each other.
- on scroll event
- creating ajax request to some URL
- receiving responses to these requests.
There can be any relative order of these once the first request is fired.
So my question being is there two different processes running at the same time?
- one to listen to on-scroll events.
- one to listen to the received response.
If so how is it synchronized on the event loop and how does the process run (given the single-threaded nature of js and possible single-core environment)?
Are these processes spanned by the browser? If so how is the synchronism maintained between event loop, browser stack, execution stack, and these processes?