Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solid-primitives/script-loader

Package Overview
Dependencies
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-primitives/script-loader

Primitive to load scripts dynamically

  • 1.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
decreased by-12.23%
Maintainers
3
Weekly downloads
 
Created
Source

Solid Primitives Script Loader

@solid-primitives/script-loader

turborepo size size stage

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({
  src: string | Accessor<string>, // url or js source
  type?: string,
  onload?: () => void,
  onerror?: () => void
});

// For example, to use recaptcha:
createScriptLoader({
  src: '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'});
    // do your stuff...
  }
});

// or pinterest embeds:
const pinterestEmbedScript = '!function(a,b,c){var d,e,f;d="PIN_"+~~((new Date).getTime()/864e5),...';
createScriptLoader({
  src: pinterestEmbedScript,
  onload: () => window?.PinUtils?.build()
});

Demo

TODO

Changelog

See CHANGELOG.md

Keywords

FAQs

Package last updated on 18 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc