Added delay
option to reduce impact on CDNs and servers [alternative without data-attributes]
#217
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📒 This is an alternative to #213 without using data-attributes
Added the
delay
option, which is useful to prevent QuickLink from prefetching too much links and have a heavy impact on CDN and servers.Unlike
throttle
option which prefetches the links in order of appearance, this option makes sure the links currently inside the viewport are prefetched.So for example, having 40 links in the page and users scrolling down fast to the 40th...
throttle: 4
, QuickLink prefetches the first 4 links, then the 5th, 6th, 7th ... and finally the 40thdelay: 500
, QuickLink prefetches only the first ones that are in viewport, then if users scroll fast enough, the 39th, the 40th, etc. because the previous 38 links didn't stay in-viewport for 500 msNote that the
throttle
anddelay
options can still be used together.I hope you like and merge this PR.