2.0.0 • Published 2 years ago

load-script v2.0.0

Weekly downloads
846,976
License
MIT
Repository
github
Last release
2 years ago

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

haravan-react-componentsreact-player-eurosport@riparide/react-playervue-canvas-video-player-betaaka-editorreact-sropbox-savercliniasearchreact-player-ott-supportreact-mathjax-updatedmingdao-web-mohodatahzero-boothzero-boot-pure@network-leads/contractscontracts-network-leads5-htp@nebulars/bury@nebular.js/bury@infinitebrahmanuniverse/nolb-loa@zawi/react-mathjax@linkiwi/react-mathjaxmingdao-web-mo@everything-registry/sub-chunk-2091snbc-paas-bootcpaas-bootkazuldur-react-playerkhuya-playergoogle-picker-componentgoogle-componentlatex2js-mathjaxlazy-routerireact-playerireactplayeritem-bankitem-bank-customitem-bank-testload-es6-promiseload-script-globalload-script-oncenice-uimap-distancemap-divmorphizm-react-playermv-reusable-componentsmy-react-playerncsa-scheduler-integrationnetplayerm-zhinanmao-utilsm2m-chartjs-plugin-crosshairmaestro-react-playermidi-sdklrm-video-playermingdao-web@valosan/react-google-picker@spce/react-player@soundsright/auth@redext/micro@topol.io/editor@vibbio/react-player@vibbio/react-player-2@vibbio/slideshow-player@vibbio/time-marker@seo-booster/wtf-ckeditor4-angular@prestashopcorp/chargebee-vue@prisma-cms/front@pythonnut/react-mathjax@sigma-page/micro@nteract/mathjax@notacademicduck/react-mathjax@mario.mac.rc/sldp-react-player@simonlc/youtube-player@sodalife/share.js@rwacross/youtube-player@rox123/import_test@stinkstudios/component-videoairtap@wizedemy/react-playeralloyeditor-react-component@webiny/app-graphql-playground@webutils/uploader@yelo/geo-positionairmap-map-sdkairframe-redely-ckeditor4-vueamap-div@wingsplatform/pay@wendina/engine@webiny/ui@zaptime/vue3@voltra/vue-playerbee-pluginbee-plugin-boostcom@abutkeev/react-player@3m/html@academix/react-player@axolo/leovuecinema8-react-player@codedown/react-playerblondie-platform-webblueberry-react-player@bassem97/upup@being_z/react-components-core
2.0.0

2 years ago

1.0.0

9 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

11 years ago