preload.io-raw
Preload.io loader to expose the raw response body
Installation
npm i preload.io-raw
Polyfills
The loader requires a few polyfills to work everywhere, to give some flexibility they are not included by default.
npm i -S whatwg-fetch regenerator
Regenerator
is currently a requirement for the async stuff, but a version is included with babel-polyfill
so if you’re using that then you’re good to go. Use whichever version of fetch
you like, if necessary.
There will be a fairly obvious console error logged if these are omitted.
Getting Started
Install preload.io and register the raw loader with it
let preloader = preloader
Then just load the resource and listen for the response
let id = preloader preloader
Passing options to fetch
RawLoader
uses fetch
to preload the resource, options you supply will be passed to fetch
, in this order of precedence:
preloader
const rawLoader = mode: 'no-cors'
const preloader = mode: 'no-cors'