load-script

WebJar for load-script

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

load-script
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

load-script
WebJar for load-script
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/eldargab/load-script

Download load-script

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/load-script/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>load-script</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/load-script/
implementation 'org.webjars.npm:load-script:1.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/load-script/
implementation ("org.webjars.npm:load-script:1.0.0")
'org.webjars.npm:load-script:jar:1.0.0'
<dependency org="org.webjars.npm" name="load-script" rev="1.0.0">
  <artifact name="load-script" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='load-script', version='1.0.0')
)
libraryDependencies += "org.webjars.npm" % "load-script" % "1.0.0"
[org.webjars.npm/load-script "1.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

load-script

Dynamic script loading.

Installation

via component

$ component install eldargab/load-script

via npm

$ npm install load-script

API

load-script appends a script node to the <head> element in the dom.

require('load-script') returns a function of the following interface: function(url[, opts][, cb]) {}

url

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

[, opts]

A map of options. Here are the currently supported options:

  • async - A boolean value used for script.async. By default this is true.
  • attrs - A map of attributes to set on the script node before appending it to the DOM. By default this is empty.
  • charset - A string value used for script.charset. By default this is utf8.
  • text - A string of text to append to the script node before it is appended to the DOM. By default this is empty.
  • type - A string used for script.type. By default this is text/javascript.

[, 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.

Example Usage

var load = require('load-script')

load('foo.js', function (err, script) {
  if (err) {
    // print useful message
  }
  else {
    console.log(script.src);// Prints 'foo'.js'
    // use script
    // note that in IE8 and below loading error wouldn't be reported
  }
})

License

MIT

Versions

Version
1.0.0