remote-script

Programmatically Loads remote scripts via script tag

Usage no npm install needed!

<script type="module">
  import remoteScript from 'https://cdn.skypack.dev/remote-script';
</script>

README

remote-script

Version Build Status Coverage Dependencies Vulnerabilities License Types

Programmatically Loads remote scripts via script tag.

Install

npm install remote-script

Usage

import load from 'remote-script';

/* Basic usage */
load('https://example.com/some-script.js')
  .then((e) => {
    if (!e) console.log('loaded');
    else console.log('ErrorEvent object', e);
  })
  .catch((err) => {
    console.log('Runtime error', err)
  });

/* Async attribute */
load('https://example.com/some-script.js', { async: true })
  .then(() => { /* ... */ });
  .catch(() => { /* ... */ });