Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identifying web workers environment?

Is it possible to determine whether or not Javascript is running in a Web Worker context?

like image 614
Stephen Belanger Avatar asked Nov 14 '22 07:11

Stephen Belanger


1 Answers

Look for the typeof one of the objects (document, window, parent) that a web worker context cannot gain access to.

like image 167
Alex K. Avatar answered Nov 16 '22 02:11

Alex K.