fetch-inject
Advanced tools
Comparing version 1.4.2 to 1.4.3
/** | ||
* Fetch Inject | ||
* Copyright (c) 2017 Josh Habdas | ||
* Build: 2017-03-16T02:47:35+08:00 | ||
* Build: 2017-03-20T22:51:16+08:00 | ||
* @licence MIT | ||
@@ -5,0 +6,0 @@ */ |
/** | ||
* Fetch Inject | ||
* Copyright (c) 2017 Josh Habdas | ||
* Build: 2017-03-16T02:47:36+08:00 | ||
* Build: 2017-03-20T22:51:17+08:00 | ||
* @licence MIT | ||
@@ -5,0 +6,0 @@ */ |
/** | ||
* Fetch Inject | ||
* Copyright (c) 2017 Josh Habdas | ||
* Build: 2017-03-16T02:47:34+08:00 | ||
* Build: 2017-03-20T22:51:15+08:00 | ||
* @licence MIT | ||
@@ -5,0 +6,0 @@ */ |
/** | ||
* Fetch Inject | ||
* Copyright (c) 2017 Josh Habdas | ||
* Build: 2017-03-16T02:47:34+08:00 | ||
* Build: 2017-03-20T22:51:15+08:00 | ||
* @licence MIT | ||
@@ -5,0 +6,0 @@ */ |
@@ -46,3 +46,3 @@ { | ||
"homepage": "https://github.com/jhabdas/fetch-inject#readme", | ||
"version": "1.4.2" | ||
"version": "1.4.3" | ||
} |
@@ -36,3 +36,3 @@ # Fetch Inject | ||
Grab the library from NPM with `npm i fetch-inject` or Bower with `bower install fetch-inject`. Recommended placement shown here: | ||
Grab the library from NPM with `npm i fetch-inject` or Bower with `bower install fetch-inject`. Suggested placement shown here: | ||
@@ -42,9 +42,9 @@ ```html | ||
<meta charset="utf-8"> | ||
<script async defer "/js/async/script.js"></script> | ||
<script async defer "/js/vendor/script.js"></script> | ||
<script> | ||
(function () { | ||
(function (window, document, undefined) { | ||
if !(window.fetch) return | ||
// contents of fetch-inject.min.js | ||
// YOUR CODE HERE | ||
})() | ||
})(window, document) | ||
</script> | ||
@@ -104,4 +104,4 @@ </head> | ||
fetchInject([ | ||
'bower_components/jquery/dist/jquery.js', | ||
'bower_components/what-input/dist/what-input.js' | ||
'/bower_components/jquery/dist/jquery.js', | ||
'/bower_components/what-input/dist/what-input.js' | ||
]) | ||
@@ -154,4 +154,4 @@ ``` | ||
fetchInject([ | ||
'https://cdn.jsdelivr.net/normalize/5.0.0/normalize.css', | ||
'//cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js', | ||
'https://cdn.jsdelivr.net/drop/1.4.2/js/drop.min.js', | ||
'https://cdn.jsdelivr.net/drop/1.4.2/css/drop-theme-arrows-bounce.min.css' | ||
]) | ||
@@ -172,3 +172,2 @@ ``` | ||
'https://npmcdn.com/tether@1.2.4/dist/js/tether.min.js', | ||
'https://cdn.jsdelivr.net/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css' | ||
]).then(() => { | ||
@@ -187,3 +186,3 @@ fetchInject([ | ||
**Solution:** | ||
This is precisely why `fetchInject` was created: | ||
This is precisely the kind of activity `fetchInject` works best at: | ||
@@ -204,7 +203,33 @@ ```js | ||
## Limitations | ||
### Managing Asynchronous Dependencies | ||
- Currently supports only `script` and `style` elements. | ||
- Relative paths (e.g. `url(default-skin.png)`) may need to be adjusted. | ||
**Problem:** | ||
You want to load some dependencies which requires some dependencies, which requires a dependency. | ||
**Solution:** | ||
You could scatter some `link`s into your document head, blocking initial page render and bloat your application bundle. Or... | ||
```js | ||
const tether = ['/js/tether.min.js'] | ||
const drop = [ | ||
'/js/drop.min.js', | ||
'/css/drop-theme-arrows-bounce.min.css' | ||
] | ||
const tooltip = [ | ||
'/js/tooltip.min.js', | ||
'/css/tooltip-theme-arrows.css' | ||
] | ||
fetchInject(tether) | ||
.then(() => fetchInject(drop)) | ||
.then(() => fetchInject(tooltip)) | ||
.then(() => { | ||
new Tooltip({ | ||
target: document.querySelector('h1'), | ||
content: "You moused over the first <b>H1</b>!", | ||
classes: 'tooltip-theme-arrows', | ||
position: 'bottom center' | ||
}) | ||
}) | ||
``` | ||
## Supported Browsers | ||
@@ -225,7 +250,5 @@ | ||
For different module types adjust the `format` setting in `rollup.config.js`. | ||
## Contributing | ||
Please use [Issues](https://github.com/jhabdas/fetch-inject/issues) to submit bugs and enhancement requests only. Pull Requests accepted and appreciated. For Node support prior to the acceptance of the [ES6 Modules proposal](https://github.com/nodejs/node-eps/blob/master/002-es6-modules.md), please create fork and mind the licensing terms. Thank you. | ||
Please use [Issues](https://github.com/jhabdas/fetch-inject/issues) for bugs and enhancement requests only. If you need support, you know [where to go](http://stackoverflow.com/). Thanks! | ||
@@ -232,0 +255,0 @@ ## See Also |
@@ -14,3 +14,3 @@ import uglify from 'rollup-plugin-uglify' | ||
license({ | ||
banner: `Copyright (c) <%= moment().format('YYYY') %> Josh Habdas\nBuild: <%= moment().format() %>\n@licence MIT` | ||
banner: `Fetch Inject\nCopyright (c) <%= moment().format('YYYY') %> Josh Habdas\nBuild: <%= moment().format() %>\n@licence MIT` | ||
}) | ||
@@ -17,0 +17,0 @@ ] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
23705
182
257