Show HN: Make your site’s pages faster than instant in one minute
instant.page
instant.page
The two other use cases you mention aren’t common at all though.
[Edit: I was using a blocker that was blocking it. Now I've used it and can tell it's working, and I still don't notice any problems using it in Safari.]
> Safari 13.0 has support for <link rel="prefetch"> but it’s disabled by default. Hopefully it will be enabled in September 2020 in Safari 14.0.
Try enabling that setting or using another browser (I used Firefox) to see the effect it has.
If it happens on all sites at the same time it’s one thing. If it happens on just your site I will just feel like your site is icky (and I might not even know why).
based on which data? Drag-dropping links to other applications is quite useful.
We'll, lets hope most users of this do indeed load it from your domain, so my scriptblocker will stop it.
I do this a lot as well.
This breaks the standard GUI interaction model. Buttons are typically triggered on mouse-up events, not mouse-down, and there's probably good reasons for that.
Any client-side hacks that attempt to improve the perceived page speed are somehow bound to break something. If there really is a simple way, it's already been implemented at the browser level, for all websites. Link prefetching is already a thing. Do you want fast pages? Make your server-side rendering fast.
Yeah.. imagine being so thirsty for page load efficiency that you ignore all the bloat of JavaScript and poor server-side rendering but instead directly skip to breaking the standardized GUI/UX
So you can drag the link somewhere else. Like to the desktop or a text editor or a terminal window.
Another piece of software egregious for violating this UI convention is Adobe Reader. I remember upgrading to, IIRC v9? and finding that all buttons in it had been changed to actuate on mouse-down, and wondering what the christ the developers were thinking. Perhaps they thought it made their software seem more "responsive".
No way would I go past 1.2.2, though, because all it does is introduce more configurability that I don’t want, complications, bugs and misfeatures. (I call triggering load on mouse down catastrophically wrong, 100% dealbreaker with prejudice.)
Here’s the ECMAScript Module (I call it a module so I can skip an IIFE without polluting globals) that I ended up with, in case anyone’s interested. It uses uncommon tricks like reusing variables for different purposes to save a couple of bytes, which will tend to make JITs unhappy, but the JIT would turn up its nose at this lightly-called functionality anyway.
/*! instant.page v1.2.2, (C) 2019 Alexandre Dieulot, https://instant.page/license, shrunk by Chris Morgan */var e,t,a,r=document,n=r.createElement("link"),s=n.relList,o=()=>{e=n.removeAttribute("href")},i=e=>{e.relatedTarget&&e.target.closest("a")==e.relatedTarget.closest("a")||(t?(clearTimeout(t),t=0):o())},c=t=>!(!t||!t.href)&&(e!=(t=t.href)&&((t=new URL(t)).origin==location.origin&&(!t.hash||t.pathname+t.search!=location.pathname+location.search)));!(s&&s.supports&&s.supports(n.rel="prefetch"))||(s=navigator.connection)&&s.saveData||(r.head.appendChild(n),r.addEventListener("touchstart",t=>{a=performance.now(),c(s=t.target.closest("a"))&&(s.addEventListener("touchcancel",o,{passive:!0}),s.addEventListener("touchend",o,{passive:!0}),n.href=e=s.href)},s={capture:!0,passive:!0}),r.addEventListener("mouseover",r=>{performance.now()-a<1100||c(s=r.target.closest("a"))&&(s.addEventListener("mouseout",i,{passive:!0}),e=s.href,t=setTimeout(()=>{n.href=s.href,t=0},65))},s))
I have the golfed-but-not-uglified code too, but I won’t share it here at this time. It’s more fun this way.(No warranty whatsoever, don’t think I’ve even run the code.)
More recent additions to the fleet include: https://www.bmwusa.com/ https://css-tricks.com/ https://www.juul.com/
What you might mean is "prerendering", i.e. silently downloading another page in the background. This feature is not yet supported in Firefox, but heavily used by Google and in Chrome. IIRC, earlier Firefox versions actually supported this through addons, but these addons did not know the page and pre-loaded every link they could find on the page. This resulted in an enormous amount of background traffic, essentially wasted due to only one link being the "next" link. Therefore, using the preload/prefetch/prerender link attributes should be left to the site owner.
Here's a good resource on preload (same page), prefetch (next page) and preconnect (other source domains): https://www.machmetrics.com/speed-blog/guide-to-browser-hint...
Edit: as Arkanosis mentioned in a related comment, the refered to addon was called Fasterfox: http://fasterfox.mozdev.org/faq.html#What_is_prefetching
Hope it doesn't come to email, for me I don't load remote content but not sure how to play in tracking over there.
It's not the job of a framework to make such optimizations. But within any framework, you could trivially implement something similar. You could be quite aggressive and fetch + cache on hover.
IIRC back in the day, google used a similar trick, where it would preload the first few search results to make them load from cache in the 90% of the cases when a user clicked on them