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

dynamic-script

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynamic-script

Extremely simple dynamic script loading with promise API

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-28.57%
Maintainers
1
Weekly downloads
 
Created
Source

dynamic-script

Greenkeeper badge Travis badge standard badge npm

Extremely simple dynamic script loader with promise API

Companion to dynamic-style

Goals

  • Simple and readable source code
  • Small API
  • Fully tested

Install

$ npm install dynamic-script

Usage

const loadScript = require('dynamic-script')

// url is set as <script src="${url}">
loadScript('https://url.com/script.js')
  .then(() => console.log('loaded successfully'))
  .catch(() => console.log('script failed to load'))

// resolves with the appended script element
const elem = await loadScript('https://url.com/script.js')
elem.src // https://url.com/script.js

Configure by passing a script element. It will be used instead of creating a new element.

const scriptTag = document.createElement('script')
scriptTag.async = false

await loadScript('https://url.com/script.js', scriptTag)

Keywords

FAQs

Package last updated on 04 Oct 2018

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