🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

remote-web-worker

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remote-web-worker

Cross origin web worker

0.0.2
Source
npm
Version published
Weekly downloads
9.7K
7.39%
Maintainers
1
Weekly downloads
 
Created
Source

Remote Worker

Leightweight (~300b) Worker patch to allow loading scripts from remote URLs

Installation

npm install --save-dev remote-web-worker

Usage

Apply Patch

import 'remote-web-worker';

Initialize a Worker just like you would normally do:

const worker = new Worker(
  'https://cdn.jsdelivr.net/npm/console-log-hello-world',
  { type: 'classic' }
);

How it works

According to spec the Worker constructor accepts only local URLs, not remote URLs: https://developer.mozilla.org/en-US/docs/Web/API/Worker/Worker

As a workaround this patched Worker will use importScripts to load the remote script. https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts

Compatibility

  • Chrome 4+
  • Firefox 4+
  • Safari 4+

Limitations

  • Only supports type="classic" workers (no import or export)

License

MIT

FAQs

Package last updated on 20 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts