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. These paths are relative to html document base URL.
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 Standard (HTML)|
BCD tables only load in the browser