Okiba / ResourceLoader
Manages loading of resources trough fetch to boost caching.
Transparently relies on a WebWorker if possible to load on a separate thread.
Untranspiled code. đ
Okiba is transpiled for browser usage only. If you use it in production, don't forget to transpile it with your bundler.
__
import ResourceLoader from '@okiba/resource-loader'
const resLoader = new ResourceLoader()
urls.forEach(
url => resLoader.load(url)
.then(console.log('Loaded! đŚ'))
.catch(console.log('Fail! âšď¸'))
)
Installation
You can grab it as an npm package
npm i --save @okiba/resource-loader
Or use it in the browser
<script src="https://unpkg.com/@okiba/resource-loader@0.1.18/dist/index.min.js"></script>
<script src="https://unpkg.com/@okiba/resource-loader@0.1.18/dist/index.js"></script>
Todo:
- Handle abortion
- Fetch is not on IE11
- Clone response and pass it as promise reslult
load(url)
Initiates loading of a resource at a given URL
Arguments
+ url: String
Resource URL
Returns
Promise A promise which will be resolved if the resource
is loaded and rejected if not.