importScripts() method of the
WorkerGlobalScope interface synchronously imports one or more scripts into the worker's scope.
self.importScripts('foo.js'); self.importScripts('foo.js', 'bar.js', ...);
A comma-separated list of
DOMString objects representing the scripts to be imported.
NetworkErroris raised if the MIME type of one of the script is
audio/*. It should always be
If you had some functionality written in a separate script called
foo.js that you wanted to use inside worker.js, you could import it using the following line:
self.importScripts() are effectively equivalent — both represent
importScripts() being called from inside the worker's inner scope.
|HTML Living Standard
The definition of 'importScripts()' in that specification.
|Feature||Android webview||Chrome for Android||Edge mobile||Firefox for Android||Opera Android||iOS Safari||Samsung Internet|