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

external-load

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

external-load

This small library helps you to load external javascript / css from url

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

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

external-load

This small function helps you to load external CSS / Javascript from url.

It's helpful if you are using some framework, and code that you wanted to use is not directly supported by that framework, and you don't want to put load scripts into your html (why? code splitting).

Load is a immediately invoked function which returns 3 functions that you may use;

Load.js()
Load.css()
Load.img()

This functions take url and return promise. In case off error, you can catch it.

Usage

import Load from 'external-load';

Load.js('https://js.stripe.com/v3/')
    .then( () => {
        // Stripe is now avaliable
        const stripe = Stripe(environment.stripeKey);
    })
    .catch( error => {
        console.log(error)
    })

Credit

This function is taken from David Walsh's [Create a Basic Loader with JavaScript Promises](Create a Basic Loader with JavaScript Promises) tutorial. Reason I'm publishing is; It's been very useful for me, and It's hard to find the code.

Keywords

FAQs

Package last updated on 10 Nov 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