simple-load-script
Advanced tools
Comparing version 1.0.2 to 1.0.3
# changelog | ||
## 1.0.3 | ||
* update 2do | ||
* update readme | ||
* update dev deps | ||
## 1.0.2 | ||
@@ -4,0 +9,0 @@ * added `insertInto` config option |
{ | ||
"name": "simple-load-script", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Very simple promise based script and JSONP", | ||
@@ -14,6 +14,32 @@ "repository": "tomek-f/simple-load-script", | ||
], | ||
"main": "simpleLoadScript.js", | ||
"scripts": { | ||
"prepare": "npm run build", | ||
"makedir": "mkdirp ./es5 && mkdirp ./es5-umd", | ||
"browserify": "browserify es6/simpleLoadScript.js -s simpleLoadScript -t babelify -o es5-umd/simpleLoadScript.js", | ||
"umd": "npm run makedir && npm run browserify", | ||
"es5": "babel es6 --out-dir es5", | ||
"es5-watch": "babel es6 --out-dir es5 --watch", | ||
"umd-watch": "watch-run -i -p 'es6/simpleLoadScript.js' npm run umd", | ||
"build": "npm run umd && npm run es5", | ||
"watch": "npm run umd-watch & npm run es5-watch" | ||
}, | ||
"files": [ | ||
"es6", | ||
"es5", | ||
"es5-umd" | ||
], | ||
"main": "es5/simpleLoadScript.js", | ||
"author": "Tomek Fijoł <tomekfijol@gmail.com> (http://tomekf.pl/)", | ||
"license": "MIT", | ||
"readmeFilename": "README.md" | ||
"readmeFilename": "README.md", | ||
"devDependencies": { | ||
"@babel/cli": "^7.13.14", | ||
"@babel/core": "^7.13.14", | ||
"@babel/preset-env": "^7.13.12", | ||
"babel-plugin-add-module-exports": "^1.0.4", | ||
"babelify": "^10.0.0", | ||
"browserify": "^17.0.0", | ||
"mkdirp": "^1.0.4", | ||
"watch-run": "^1.2.5" | ||
} | ||
} |
@@ -5,3 +5,2 @@ # simple-load-script | ||
* tiny | ||
* Promise based ([use polyfill if you need](http://caniuse.com/#feat=promises)) | ||
@@ -16,6 +15,19 @@ * uses addEventListener (IE9+) | ||
## Import | ||
```js | ||
// es5 CommonJS | ||
const loadScript = require('simple-load-script'); | ||
// es6 | ||
const loadScript = require('simple-load-script/es6/simpleLoadScript'); | ||
// es5-umd | ||
const loadScript = require('simple-load-script/es5-umd/simpleLoadScript'); | ||
``` | ||
## Usage | ||
```js | ||
var loadScript = require('simple-load-script'); | ||
import loadScript from 'simple-load-script'; | ||
@@ -32,4 +44,14 @@ loadScript('//code.jquery.com/jquery-2.2.3.js') | ||
```js | ||
var loadScript = require('simple-load-script'); | ||
import loadScript from 'simple-load-script'; | ||
try { | ||
/* const scriptRef = */ loadScript('//code.jquery.com/jquery-2.2.3.js'); | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
``` | ||
```js | ||
import loadScript from 'simple-load-script'; | ||
loadScript('//code.jquery.com/jquery-2.2.3.js', { | ||
@@ -47,3 +69,3 @@ inBody: true | ||
```js | ||
var loadScript = require('simple-load-script'); | ||
import loadScript from 'simple-load-script'; | ||
@@ -65,3 +87,3 @@ loadScript({ | ||
```js | ||
var loadScript = require('simple-load-script'); | ||
import loadScript from 'simple-load-script'; | ||
@@ -100,3 +122,3 @@ loadScript({ | ||
```js | ||
var loadScripts = require('simple-load-script').all; | ||
import loadScript from 'simple-load-script'; | ||
@@ -116,6 +138,6 @@ loadScripts( | ||
Load more scripts (Promise.all) - objects and urls, callback must be unique names | ||
Load more scripts (Promise.all) - objects and urls, callBackNames must be unique names | ||
```js | ||
var loadScripts = require('simple-load-script').all; | ||
import loadScript from 'simple-load-script'; | ||
@@ -166,46 +188,4 @@ loadScripts( | ||
## UMD (CommonJS, AMD, global, ES6) | ||
### CommonJS | ||
```js | ||
var loadScript = require('simple-load-script'); | ||
loadScript(/**/); | ||
``` | ||
### AMD | ||
```js | ||
define(['simple-load-script'], function(loadScript) { | ||
loadScript(/**/); | ||
}); | ||
``` | ||
### Global (in window object) | ||
```js | ||
simpleLoadScript(/**/); | ||
``` | ||
### ES6 (ES2015) modules | ||
* loading ES5 module | ||
```js | ||
import loadScript from 'simple-load-script'; | ||
loadScript(/**/); | ||
``` | ||
## Promise polyfill | ||
Good example | ||
```bash | ||
npm install es6-promise --save | ||
``` | ||
## Changelog | ||
[View on github](https://github.com/tomek-f/simple-load-script/blob/master/changelog.md). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21564
351
8
184
3
1