Package Exports
- @jongleberry/load-script
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@jongleberry/load-script) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@jongleberry/load-script
Script loader with:
Promise
supportrequestIdleCallback
support
Installation:
npm install --save-dev @jongleberry/load-script
Example:
import loadScript from '@jongleberry/load-script'
loadScript('https://www.googletagmanager.com/ns.html?id=GTM-XXXX', {
timeout: 1000
}).catch((err) => {
console.error(err.stack)
})
API
const script = await loadScript(src [, options])
src
- JS source URLoptions
:type
charset
id
noModule
async
defer
timeout
- timeout passed torequestIdleCallback
, falling back tosetTimeout
. Set to 0 to load JS in at least the next tick.
Returns the script element when it's resolved.