Socket
Socket
Sign inDemoInstall

load-script-global

Package Overview
Dependencies
14
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    load-script-global

Load a global library via a script tag


Version published
Weekly downloads
501
decreased by-3.65%
Maintainers
1
Install size
176 kB
Created
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 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • 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