instantpage/instant.page

Change v3 behaviour at runtime

Closed this issue · 3 comments

Hi @dieulot,
congratulations for this script, keep up with the great work!

Is it possible to change v3’s behavior when I detect a mouse movement?

I mean: I saw that the behaviour is driven by a andata attribute in the body tag. Can I change it at runtime an make InstantPage change its behaviour, maybe calling a method on InstantPage object?

Thank you very much,
Nice touch with V3.

Sorry I need to change what I’m asking :) just to to be clear:

  1. I load the page and launch InstantPage in the most conservative version, the classic one that prefetches at MouseOver or TouchStart.
  2. We use an external library to detect if the user is not using a mouse (like on a mobile device or using a Microsoft surface using touch)
  3. We switch the data attribute on the body element, or we tell somehow InstantPage to enable the version which works with IntersectionObserver mimicking QuickLink

This request is because on full responsive websites we’d like to be able to use the more conservative behaviour on desktop, and the more aggressive one on mobile and all devices without a mouse.

Currently data-instant-intensity="viewport" preloads all visible links on small devices (phones) and use mouseover/touchstart for the rest.

I plan to introduce an option to preload visible links on every touch device, detected by the pointer media query. That would solve your request, right?

Yes it would. Thanks