fetch-inject
Advanced tools
Comparing version 1.4.3 to 1.5.0
{ | ||
"name": "fetch-inject", | ||
"description": "Inline assets into the DOM using Fetch Injection.", | ||
"main": "dist/fetch-inject.js", | ||
"description": "Dynamically inline assets into the DOM using Fetch Injection.", | ||
"main": "dist/fetch-inject.min.js", | ||
"authors": [ | ||
@@ -6,0 +6,0 @@ "Josh Habdas" |
/** | ||
* Fetch Inject | ||
* Copyright (c) 2017 Josh Habdas | ||
* Build: 2017-03-20T22:51:16+08:00 | ||
* Build: 2017-03-22T01:20:32+08:00 | ||
* @licence MIT | ||
@@ -6,0 +6,0 @@ */ |
/** | ||
* Fetch Inject | ||
* Copyright (c) 2017 Josh Habdas | ||
* Build: 2017-03-20T22:51:17+08:00 | ||
* Build: 2017-03-22T01:20:32+08:00 | ||
* @licence MIT | ||
@@ -6,0 +6,0 @@ */ |
/** | ||
* Fetch Inject | ||
* Copyright (c) 2017 Josh Habdas | ||
* Build: 2017-03-20T22:51:15+08:00 | ||
* Build: 2017-03-22T01:20:30+08:00 | ||
* @licence MIT | ||
@@ -6,0 +6,0 @@ */ |
/** | ||
* Fetch Inject | ||
* Copyright (c) 2017 Josh Habdas | ||
* Build: 2017-03-20T22:51:15+08:00 | ||
* Build: 2017-03-22T01:20:31+08:00 | ||
* @licence MIT | ||
@@ -6,0 +6,0 @@ */ |
@@ -5,6 +5,8 @@ { | ||
"module": "dist/fetch-inject.es.js", | ||
"main": "dist/fetch-inject.umd.js", | ||
"scripts": { | ||
"build": "npm run clean && npm run lint && npm run build-iife && npm run build-es", | ||
"build": "npm run clean && npm run test && npm run build-iife && npm run build-es && npm run build-umd", | ||
"build-iife": "rollup -c && MINIFIER=on rollup -c", | ||
"build-es": "FORMAT=es rollup -c && FORMAT=es MINIFIER=on rollup -c", | ||
"build-umd": "FORMAT=umd rollup -c && FORMAT=umd MINIFIER=on rollup -c", | ||
"clean": "rimraf ./dist/*", | ||
@@ -47,3 +49,3 @@ "test": "npm run lint", | ||
"homepage": "https://github.com/jhabdas/fetch-inject#readme", | ||
"version": "1.4.3" | ||
"version": "1.5.0" | ||
} |
@@ -14,5 +14,5 @@ # Fetch Inject | ||
- Wraps the [Fetch API](http://devdocs.io/dom/fetch_api) | ||
- Zero runtime dependencies | ||
- 398 bytes gzipped | ||
- Zero runtime dependencies | ||
- ES6 Module included | ||
@@ -23,34 +23,9 @@ ## Background | ||
Don't like to read? Here's a playground:<br> | ||
https://codepen.io/jhabdas/pen/MpVeOE?editors=0012 | ||
## Installing | ||
Fetch Inject is available for testing purposes [via jsDelivr](http://www.jsdelivr.com/projects/fetch-inject), and for production via NPM and Bower. | ||
Get it on NPM with `npm i fetch-inject` or Bower with `bower install fetch-inject`. Also available via CDN [using jsDelivr](http://www.jsdelivr.com/projects/fetch-inject). | ||
### For Testing | ||
Add the following to your document `head` and see the [Use Cases](#use-cases) to get a feel for what it can do: | ||
```html | ||
<script src="https://cdn.jsdelivr.net/fetch-inject/latest/fetch-inject.min.js"></script> | ||
``` | ||
### For Production | ||
Grab the library from NPM with `npm i fetch-inject` or Bower with `bower install fetch-inject`. Suggested placement shown here: | ||
```html | ||
<head> | ||
<meta charset="utf-8"> | ||
<script async defer "/js/vendor/script.js"></script> | ||
<script> | ||
(function (window, document, undefined) { | ||
if !(window.fetch) return | ||
// contents of fetch-inject.min.js | ||
// YOUR CODE HERE | ||
})(window, document) | ||
</script> | ||
</head> | ||
``` | ||
To fallback for older browsers `document.write` and `noscript` are your friends. | ||
## Usage | ||
@@ -139,3 +114,3 @@ | ||
]).then(() => { | ||
console.log(`Finish in less than ${moment().endOf('year').fromNow()}`) | ||
console.log(`Finish in less than ${moment().endOf('year').fromNow(true)}`) | ||
}) | ||
@@ -142,0 +117,0 @@ ``` |
28996
19
235
232