Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
simple-load-script
Advanced tools
Very simple promise based script loader and JSONP
npm install --save simple-load-script
var loadScript = require('simple-load-script');
loadScript('//code.jquery.com/jquery-2.2.3.js')
.then(function(scriptRef) {
console.log('success', scriptRef);
})
.catch(function(err) {
console.log(err);
});
var loadScript = require('simple-load-script');
loadScript('//code.jquery.com/jquery-2.2.3.js', {
inBody: true
})
.then(function(scriptRef) {
console.log('success', scriptRef); // 'success', script ref.
})
.catch(function(err) {
console.log(err);
});
var loadScript = require('simple-load-script');
loadScript({
url: '//code.jquery.com/jquery-2.2.3.js',
attrs: { id: 'one', charset: 'UTF-8' }
})
.then(function(scriptRef) {
console.log('success', scriptRef); // 'success', script ref.
})
.catch(function(err) {
console.log(err);
});
Google Maps API
var loadScript = require('simple-load-script');
loadScript({
url: '//maps.googleapis.com/maps/api/js?&callback=gmapiready',
callBackName: 'gmapiready'
})
.then(function(scriptRef) {
console.log('success', scriptRef); // 'success', undefined
})
.catch(function(err) {
console.log(err);
});
JSONP
var loadScript = require('simple-load-script');
loadScripts('//api.ipinfodb.com/v3/ip-city/?format=json&callback=elo', {
callBackName: 'elo',
removeScript: true
})
.then(function(scriptRef) {
console.log('success', scriptRef); // 'success', res
})
.catch(function(err) {
console.log(err);
});
Load more scripts (Promise.all) - urls
var loadScripts = require('simple-load-script').all;
loadScripts(
'//example.com/test1.js',
'//example.com/test2.js',
'//example.com/test3.js'
)
.then(function(scriptRef) {
console.log('success', scriptRef); // 'success', res
})
.catch(function(err) {
console.log(err);
});
Load more scripts (Promise.all) - objects and urls (no url-object pairs allowed), callback must be unique names
var loadScripts = require('simple-load-script').all;
loadScripts(
{
url: '//maps.googleapis.com/maps/api/js?&callback=gmapiready',
callBackName: 'gmapiready'
},
{
url: '//api.ipinfodb.com/v3/ip-city/?format=json&callback=elo',
callBackName: 'elo',
removeScript: true
},
{
url: 'https://api.twitter.com/1/statuses/oembed.json?id=507185938620219395&callback=elo2',
callBackName: 'elo2'
},
'//code.jquery.com/jquery-2.2.3.js'
)
.then(function(scriptRef) {
console.log('success', scriptRef); // 'success', array
})
.catch(function(err) {
console.log(err);
});
url
(optional) - file to append to bodyoptions
(required) - options in objecturl
(string) - file to append to bodyinBody
(boolean) - append to document.body
instead of document.head
attrs
(object) - with attributes to append to script tag (charset
, type
, id
, …)callBackName
(string) - callback to add to window
object; promise is resolved after callback is fired; callback is removed after that; multiple callbacks must have unique namesdontRemoveCallBack
(boolean) - from window
after load; no real use - let me knowremoveScript
(boolean) - after load (for JSONP, other reasons); it's always removed on errorvar loadScript = require('simple-load-script');
loadScript(/**/);
define(['simple-load-script'], function(loadScript) {
loadScript(/**/);
});
simpleLoadScript(/**/);
import loadScript from 'simple-load-script';
loadScript(/**/);
Good example
npm install es6-promise --save
1.0.0
dontRemoveCallBack
and removeScript
FAQs
Very simple promise based script and JSONP
The npm package simple-load-script receives a total of 4,487 weekly downloads. As such, simple-load-script popularity was classified as popular.
We found that simple-load-script demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.