Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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, 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
},
[
'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.1
all
methodFAQs
Very simple promise based script and JSONP
The npm package simple-load-script receives a total of 2,245 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 uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.