npm.io
1.0.0 • Published 10 years ago

tiny-load-script

Licence
MIT
Version
1.0.0
Deps
0
Vulns
0
Weekly
0

tiny-load-script

Load a javascript file and forget about it

Perfect for autonomous libraries like YouTube's and Facebook's APIs.

npm i --save tiny-load-script

The module is simply this:

/**
 * @param  {string} src  The Url to the file to load
 * @return {element}     The <script> element that is being loaded
 */
module.exports = function (src) {
    var s = document.createElement('script');
    s.src = src;
    s.async = true;
    document.head.appendChild(s);
    return s;
};