0

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 :

  1. Browser doing actual rendering
  2. User clicks -> some js code starts and ends
  3. a Timeout -> againg some js code is executed
  4. Browser does something
  5. User clicks again -> some js code start and ends
  6. ... 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 ?

  1. Browser doing actual rendering
  2. User clicks -> some js code start and ends
    -> Log task 2 : doing something
  3. a Timeout -> againg some js code is executed
  4. Browser does something
  5. User clicks again -> some js code start and ends -> Log task 5 : doing something (again)
  6. ... and so on

Yes indeed we could build our code to manage this, but it's not the actual question.

ic3
  • 7,917
  • 14
  • 67
  • 115

0 Answers0