-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow customizing the delay for InstantClick behavior #1164
base: main
Are you sure you want to change the base?
Allow customizing the delay for InstantClick behavior #1164
Conversation
263365b
to
cdf89ef
Compare
@davidalejandroaguilar what would be a use case for someone needing to change the prefetch delay? Do you think there will be cases where the difference is quite noticeable, or the default won't provide a good experience? I think it's generally good if we can keep Turbo's API simple and small, by only adding attributes/tags that many people are likely to need. If a customisation is not in high demand, it might be better to keep it out of that API. (Which is not to say there couldn't still be a way to affect it in code, if necessary.) Perhaps this is one of those common needs! But I was struggling to think of a concrete example of needing it, so was curious if you had more context about why the setting needs to be exposed. Thanks! |
I agree with @kevinmcconnell. I'd like to see some practical cases where we need this before expanding the public API. Another thing to note is that we may add InstaClick for keyboard navigation, but that could need different timing. It'd be useful to know what we're going to do with the keyboard events, and if we need different delays for different events, before committing to an API for this. |
cdf89ef
to
28fa3fb
Compare
448cdd7
to
cdf89ef
Compare
d22bcce
to
617a1bd
Compare
My two cents: I'd find actually increasing the prefetch delay useful. |
Description
This PR adds a configurable delay to the new InstantClick behavior.
The 100 ms default is a nice one. However, some apps might be fine with having no delay and would prefer to prefetch as soon as possible, so let's provide sharp knives.
Configuration
data-turbo-prefetch-delay
attribute on the<a>
element.turbo-prefetch-delay
meta tag.Both can be set to any numerical value, or to
"0"
for no delay. Note that the latter means thatsetTimeout
won't be used at all, so it will be an instant prefetch.Notes
I also thought about using
"false"
instead of"0"
for no delay, let me know if that or something else is preferred.