New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@braintree/asset-loader

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@braintree/asset-loader - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# 0.2.1
* Set `loadScript` to cache the promise used to load the script to eliiminate a race condition where the script could be on the page, but not ready to use
# 0.2.0

@@ -2,0 +6,0 @@

24

load-script.js
'use strict';
var Promise = require('./lib/promise');
var scriptPromiseCache = {};
module.exports = function loadScript(options) {
var attrs, container, script;
function loadScript(options) {
var attrs, container, script, scriptLoadPromise;
var stringifiedOptions = JSON.stringify(options);
if (!options.forceScriptReload) {
script = document.querySelector('script[src="' + options.src + '"]');
scriptLoadPromise = scriptPromiseCache[stringifiedOptions];
if (script) {
return Promise.resolve(script);
if (scriptLoadPromise) {
return scriptLoadPromise;
}

@@ -28,3 +30,3 @@ }

return new Promise(function (resolve, reject) {
scriptLoadPromise = new Promise(function (resolve, reject) {
script.addEventListener('load', function () {

@@ -41,2 +43,12 @@ resolve(script);

});
scriptPromiseCache[stringifiedOptions] = scriptLoadPromise;
return scriptLoadPromise;
}
loadScript.clearCache = function () {
scriptPromiseCache = {};
};
module.exports = loadScript;
{
"name": "@braintree/asset-loader",
"version": "0.2.0",
"version": "0.2.1",
"description": "A module to load frontend assets.",

@@ -5,0 +5,0 @@ "main": "index.js",

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