Without using Workers the javascript code is executed in a browser in a single threaded mode (check this entry). To simplify we can say that a browser is going to call some js code on events, timeouts, and ajax returns waiting patiently for completion (if no you get a freeze).
Let's imagine this workflow :
- Browser doing actual rendering
- User clicks -> some js code starts and ends
- a Timeout -> againg some js code is executed
- Browser does something
- User clicks again -> some js code start and ends
- ... and so on
The questions, is there a way to have an unique Id from the browser each time so when logging some events we know it is a different task that is being executed ?
- Browser doing actual rendering
- User clicks -> some js code start and ends
-> Log task 2 : doing something - a Timeout -> againg some js code is executed
- Browser does something
- User clicks again -> some js code start and ends -> Log task 5 : doing something (again)
- ... and so on
Yes indeed we could build our code to manage this, but it's not the actual question.