fireship-io / flamethrower

A blazingly fast router for static sites
MIT License
2.79k stars 109 forks source link

Feat: Adding prefetch on hover #17

Closed b0iq closed 2 years ago

b0iq commented 2 years ago

I suggest adding prefetch on hover only which is optimize the library for large page with a lot of links.

Tropix126 commented 2 years ago

Hmmm, just an idea. Would it be more future-proof to add a property such as { prefetchBehavior: "hover" } rather than a boolean in this case? Might mitigate the amount of config fluff in the future if more prefetch options end up being added.

b0iq commented 2 years ago

@Tropix126 Great!, I was thinking about that too, but I don't want my PR looks dirty with a lot of new features such as enums...etc. So for know I think it is good enough. Or if it was so important to be implemented now, I can continue developing it; if any of the reviewers tell me his opinion 😄

codediodeio commented 2 years ago

Good idea, thanks! I'd prefer { prefetch: "hover" } since it would make no sense to use both hover and intersection at the same time. The interface could look like prefetch?: 'visible' | 'hover'.

ekwoka commented 2 years ago

An option seems nice.

Since then the api could support something like an options for maybe I want visible but only links of a certain kind (main links), not necessarily all links.

b0iq commented 2 years ago

@codediodeio Done 🔥

abdurahmanshiine commented 2 years ago

I agree, having options is better

b0iq commented 2 years ago

@ekwoka Cool, do you me we should achieve that by add an attribute to certain elements that is requiring prefetching such as: <a href="/about" prefetch >About</a>?

ekwoka commented 2 years ago

@b0iq Yeah, something like that.

probably more like data-prefetch but even have it configurable.