Socket
Socket
Sign inDemoInstall

third-partay.js

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

third-partay.js

A tiny library that loads and manages external third-party JavaScript snippets.


Version published
Maintainers
1
Created
Source

ThirdPartay.js

ThirdPartay.js on NPM

A tiny library that loads and manages external third-party JavaScript snippets.

About

Sometimes you need to include a vendor's third party "cut and paste" JavaScript snippet in your project. ThirdPartay is a tiny, dependency-free library that gives you basic loading, management, and callback capabilities (via ES6 promises) over those unruly snippets. With ThirdPartay, you can bridge the gap between your own code and external vendor-provided scripts.

Usage

To use ThirdPartay, you'll need a modern JavaScript workflow and build system with ES6 module bundling and transpiling capabilities. Here's a great example. ThirdPartay makes use of ES6 promises, which are supported in modern browsers. To support older browsers, you might need to polyfill.

Install

Install ThirdPartay via NPM and add to your dependencies:

$ npm install third-partay.js --save

Initialize

Import the ThirdPartay module, then instantiate it. The constructor takes an optional selector argument, this is the selector to which your third party scripts will be appended. The default document.body should be fine in most cases.

// import ThirdPartay
import ThirdPartay from 'third-partay.js'

// create an instance
const Party = new ThirdPartay()

Each instance represents a group of external scripts. You can add as many scripts to an instance as you'd like.

Party.add('//cdn.urltoyourvendorsscript.com/script.js')
Party.add('//static.urltoanothervendorsscript.com/script.js')

Each instance returns a promise when all member scripts are loaded, allowing you to create intelligent groups of third party snippets with asynchronous promise-driven callbacks. Add a callback function to your instance to execute it once all of the instances scripts have been loaded.

Party.loaded((returned) => {
  console.log(returned);
});

License

MIT. © 2016 Donny West

Built With Swag

Keywords

FAQs

Package last updated on 29 Mar 2016

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