2.0.0 • Published 4 years ago

load-script v2.0.0

Weekly downloads
846,976
License
MIT
Repository
github
Last release
4 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-bootwix-react-playervvv-searchform-widgetwaiqin365-modulewd-react-intl-universalvue-naver-mapws-canvasws-china-area-datasvelte-playertianji-client-sdkvpg-react-mathjaxvue-gpickervue-core-epic-playervue-coin-hivevue-core-video-playervue-core-video-playersviskan-deku-recaptchavue-dropbox-chooservue-ecommercevue-email-buildervue-canvas-video-player@dragit/editor-plugin-vue@cloudgeek/playcore-hls@cloudgeek/vue3-video-player@codedown/react-player@core-player/playcore-hls@cpreston321/react-player@rox123/import_test@prestashopcorp/chargebee-vue@prisma-cms/frontitem-bankitem-bank-2item-bank-customitem-bank-testireactplayerireact-playerkazuldur-react-playerkhuya-playerlazy-routerlatex2js-mathjaxsoundcloud-loaderspa-boosttwitch-recurlytingzi-vuepresstrack.jstwintap@bankify/react-intl-universal@being_z/react-components-core@beisen-elearning/manage-courses-edit@beisen-elearning/ux-p-man-courseware-lib@beefree.io/sdk@axolo/leovue@bassem97/upup@afuggini/loadscript@brettcate/s3-react-player@celluloid/react-player@cerpus/edlib-components@0x1461a0/sd-plugin-entry@3m/html5htp-core@abutkeev/react-player@academix/react-player@lrnwebcomponents/wave-player@ddobei/ckeditor4-angularyoutube-playeryoutube-player-load_iframe_script_contentyoutube-player-with-hostyyzvue3-ssr-video-playervue-rudderstackvue-segment-analyticsvue-video-player-self-controlsvue-media-utilityvue2-httpvue2-insta-signupvue2-saas-proxyvue2-uploader-window
2.0.0

4 years ago

1.0.0

10 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

12 years ago