@solid-primitives/script-loader
Creates a primitive to load scripts dynamically, either for external services or jsonp requests
Installation
npm install @solid-primitives/script-loader
# or
yarn add @solid-primitives/script-loader
How to use it
const [script: HTMLScriptElement, remove: () => void] = createScriptLoader({
url: string | Accessor<string>,
type?: string,
onload?: () => void,
onerror?: () => void
});
createScriptLoader({
url: 'https://www.google.com/recaptcha/enterprise.js?render=my_token'
onload: async () => {
await grecaptcha.enterprise.ready();
const token = await grecaptcha.enterprise.execute('my_token', {action: 'login'});
}
});
Demo
TODO
Changelog
Expand Changelog
0.0.100
Initial release.
1.0.2
Release first first with CJS support.
1.0.3
Upgrade to Solid 1.3