asset-loader
Installation
npm install --save @braintree/asset-loader
Usage
var loadScript = require("@braintree/asset-loader/load-script");
loadScript({
src: "https://example.com/some-js-file.js",
container: domNodeToAddScriptTagTo,
id: "id-to-give-script-tag",
crossorigin: "anonymous",
dataAttributes: {
foo: "value",
},
forceScriptReload: true,
})
.then(function (script) {
script;
})
.catch(function (err) {
});
var loadStylesheet = require("@braintree/asset-loader/load-stylesheet");
loadStylesheet({
href: "https://example.com/some-css-file.css",
container: domNodeToAddScriptTagTo,
id: "id-to-give-to-stylesheet-element",
}).then(function (stylesheet) {
stylesheet;
});
Both methods will resolve immediately if the script
or link
element is already on the page.
Development
Run tests:
npm test