How can I “start and forget” the JS function? (do not wait for a refund)

I want to install a JS function, but not wait for an answer. The only way I can do this is:

setTimeout(function() { myFunc(); },0); 

But it seems ... ineffective at best. Any ideas?

+6
source share
2 answers

Why is this inefficient?

Also, don't forget that the javascript browser is single-threaded. Thus, while your function is running, you will implicitly wait for it to return.

(there could be asynchronous ajax calls here)

+3
source

You might want to watch webworkers

+12
source

Source: https://habr.com/ru/post/906397/


All Articles