speculative
npm install speculative --save
var speculative =
API
speculative(attributes)
attributes
href
: URIrel
: relationpr
: probability number between0
and1
as
: content typecrossorigin
: CORS settingmedia
: media query
rel
rel value |
Nature | Browser action |
---|---|---|
prerender | speculative | DNS lookup, TCP/TLS handshake, fetch data, execute scripts |
preload | mandatory | DNS lookup, TCP/TLS handshake, fetch data |
prefetch | speculative | DNS lookup, TCP/TLS handshake, fetch data |
preconnect | speculative | DNS lookup, TCP/TLS handshake |
dns-prefetch | speculative | DNS lookup |
Examples
Speculating navigation
Prefetching playlist tracks
Prefetching an image
Prefetching JavaScript
Prefetching CSS
Prefetch with care. Test for metered data usage
var cxn = var speculative = cxn ? {} :
License
MIT