Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

fetch-script-async

rileyhilliard5MIT1.0.0

async script fetcher to help lazy load scripts after a document has loaded

async, script, fetch, lazy-load, lazy, load

readme

fetch-script-async

Async script fetcher with a promise API to help lazy load scripts.

Installation

npm install fetch-script-async
yarn add fetch-script-async

Example

import fetchScript from 'fetch-script-async';

const GA = 'https://www.google-analytics.com/analytics.js';

fetchScript(GA).then(script => {
  // do something after google analytics has been fetched and instantiated
});

changelog

1.0.0 V1

  • Ability to fetch a script asset