You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

load-script2

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

load-script2

Dynamic script loading for modern browsers

1.0.0
Source
npmnpm
Version published
Weekly downloads
11K
-7.94%
Maintainers
1
Weekly downloads
 
Created
Source

load-script2 travis npm downloads

Dynamic script loading for modern browsers

Works in the browser with browserify!

install

npm install load-script2

usage

var load = require('load-script2')

load('foo.js', function (err, script) {
  if (err) {
    // print useful message
  }
  else {
    console.log(script.src);// Prints 'foo'.js'
    // use script
  }
})

differences to load-script

This package only supports browsers that use the standard DOM API, opting to drop non-standard browsers like IE8 and below. It also removes all the options, which aren't needed most of the time.

The minfied+gzipped size of load-script2 is 455B, compared to 645B for load-script.

API

load(src, [cb]) {}

Append a <script> node with the given src URL to the <head> element in the DOM.

url

Any url that you would like to load. May be absolute or relative.

cb

A callback function of the following interface: function(err, script) {} where err is an error if any occurred and script is the script node that was appended to the DOM.

license

MIT. Copyright (c) Feross Aboukhadijeh.

Keywords

load

FAQs

Package last updated on 21 Feb 2017

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