Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
simple-load-script
Advanced tools
Very simple promise based script loader and JSONP
import simpleLoadScript from 'simple-load-script';
try {
const scriptRef = await simpleLoadScript('//code.jquery.com/jquery-2.2.3.js');
console.log(scriptRef); // HTMLScriptElement
} catch (err) {
console.log(err);
}
import simpleLoadScript from 'simple-load-script';
simpleLoadScript('//code.jquery.com/jquery-2.2.3.js')
.then(function (scriptRef) {
console.log(scriptRef);
})
.catch(function (err) {
console.log(err);
});
import simpleLoadScript from 'simple-load-script';
try {
const scriptRef = await simpleLoadScript({
url: '//code.jquery.com/jquery-2.2.3.js',
inBody: true,
attrs: { id: 'one', charset: 'UTF-8' },
});
console.log(scriptRef); // HTMLScriptElement inBody with attrs present
} catch (err) {
console.log(err);
}
Runs global callback (window.gmapiready)
import simpleLoadScript from 'simple-load-script';
try {
const scriptRef = await simpleLoadScript('//maps.googleapis.com/maps/api/js?&callback=gmapiready');
console.log(scriptRef); // HTMLScriptElement
} catch (err) {
console.log(err);
}
Runs global callback (window.elo)
var simpleLoadScript = require('simple-load-script');
try {
const scriptRef = await simpleLoadScript({
url: '//api.ipinfodb.com/v3/ip-city/?format=json&callback=elo',
removeScript: true,
});
console.log(scriptRef); // undefined
} catch (err) {
console.log(err);
}
import simpleLoadScript from 'simple-load-script';
try {
const scriptRefs = await simpleLoadScript([
'//maps.googleapis.com/maps/api/js?&callback=gmapiready',
{
url: '//api.ipinfodb.com/v3/ip-city/?format=json&callback=elo',
removeScript: true,
},
'//code.jquery.com/jquery-2.2.3.js',
]);
console.log(scriptRefs); // HTMLScriptElement[]
} catch (err) {
console.log(err);
}
Config | string | (Config | string)[]
interface Config {
url: string;
attrs?: Record<string, string>;
inBody?: boolean;
insertInto?: string | null;
removeScript?: boolean;
}
const defaultConfig = {
url: '',
attrs: {},
inBody: false,
insertInto: null,
removeScript: false,
};
url
- file to append to bodyattrs
- with attributes to append to script tag (charset
, type
, id
, …)inBody
- append to document.body
instead of document.head
insertInto
- CSS selector (an ID, class name, element name, etc.) to insert the script into. Overrides inBody
value.removeScript
- remove script tag after load; it's always removed on an errorCheck files or package.json
FAQs
Very simple promise based script and JSONP
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.