Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

load-script-global

Package Overview
Dependencies
8
Maintainers
1
Versions
5
Issues
File Explorer

Advanced tools

load-script-global

Load a global library via a script tag

    1.0.4latest
    GitHub

Version published
Maintainers
1
Weekly downloads
936
decreased by-15.68%

Weekly downloads

Readme

Source

load-script-global Build Status Greenkeeper badge

Load a global library via a script tag

Install

$ npm install --save load-script-global

Usage

var load = require('load-script-global') load({ url: 'https://maps.googleapis.com/maps/api/js?key=k', global: 'google', jsonp: true }, function (err, google) { //=> google.Maps... })
  • Attempting to load once the library is already available will avoid creating a new <script> tag but still call the callback with the library
  • Attemtping to load the library multiple times in a row will only create a single script tag and still calls each callback

API

load(options, callback) -> undefined
options

Required
Type: object

url

Required
Type: string

The script URL.

global

Required
Type: string

The name of the window global that the script will publish.

jsonp

Type: boolean

If true, listens for success via a JSONP callback instead of on script.onload.

callback

Required
Type: function
Arguments: err, library

A callback that will be called with a loading error or the library as published on the window once available.

License

MIT © Ben Drucker

Keywords

FAQs

Last updated on 25 Jun 2019

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc