⚡️Faster subsequent page-loads by prefetching in-viewport links during idle time
threshold
option to allow users select the % of link areas that entered the viewport before (d3746e1), closes #214
hrefFn
option to build the URL to prefetch. (#201) (ee072d4), closes #201
delay
option to reduce impact on CDNs and servers [alternative without data-attributes] (#2 (5cdf569), closes #217
2.0.0 is a major rewrite of Quicklink, introducing a first-class prefetch
method that can be used in more contexts, new features like limit
, throttle
and other DX improvements.
In-viewport prefetching is now available via the listen()
method.
limit
option – total allowed requeststhrottle
option – max concurrency control via throttles
prefetch
method directlydefault
as listen
methodlisten
early if no IO supportlisten
listen
returns a reset
/ unlisten functionprefetch
to accept url[] listFor the latest documentation around this release, see https://getquick.link/
2.0 is a major rewrite of Quicklink, introducing a first-class prefetch
method that can be used in more contexts, new features like limit
, throttle
and other DX improvements. In-viewport prefetching is now available via the listen()
method.
This is a maintenance release of Quicklink 🧹The largest changes in this version are bug-fixes for Safari, docs updates and some brand new demos to learn from 🤾♂️
Quicklink attempts to make navigations to subsequent pages load faster by prefetching in-viewport links during idle time
A huge thanks to everyone that has been trying out quicklink
, sharing feedback and deploying it to production (like Hashnode and CleverTogether). We're glad you found our micro-library helpful. We've just published a new version to address early feature requests 🗣
We now support origins
: a new static array of URL hostname strings that are allowed to be prefetched. Defaults to the same domain origin, which prevents any cross-origin requests. This was a requested change in behavior from earlier versions of quicklink
which would fetch all origins by default.
You can use origins
as follows:
Specify a custom list of allowed origins
Provide a list of hostnames that should be prefetch-able. Only the same origin is allowed by default.
Important: You must also include your own hostname!
quicklink({
origins: [
// add mine
'my-website.com',
'api.my-website.com',
// add third-parties
'other-website.com',
'example.com',
// ...
]
});
Allow all origins
Enables all cross-origin requests to be made.
quicklink({
origins: true
});
We also now support ignores
which adds support for filtering. This can be a RegExp, Function, or Array that further determines if a URL should be prefetched. These filters run after the origins
matching has run.
Ignores can be useful for avoiding large file downloads or for responding to DOM attributes dynamically.
// Same-origin restraint is enabled by default.
//
// This example will ignore all requests to:
// - all "/api/*" pathnames
// - all ".zip" extensions
// - all <a> tags with "noprefetch" attribute
//
quicklink({
ignores: [
/\/api\/?/,
uri => uri.includes('.zip'),
(uri, elem) => elem.hasAttribute('noprefetch')
]
});
If you tried out the first release of quicklink
and noticed it prefetching /logout
pages, download links or any other resources you'd rather it not, this new feature should help.
This release also includes a few bug-fixes. These include URLs being prefetched are now also normalized by default (https://www.google.com
vs. https://www.google.com/
vs https:\\www.google.com/
). Thanks to @mathiasbynens for bringing this to our attention.
See API docs and recipes for details on how to use these new features. You can also find a new FAQ for answers to common questions we've had users ask about the project.
Bundle size: 782 bytes minified & gzipped. We were able to introduce new features while keeping our size down in large part thanks to clever code-golfing by @lukeed ⛳️
With huge thanks to @lukeed and our lovely contributors for all of their help with this release ❤️We couldn't have done it without you!.