instantpage / instant.page

Make your site’s pages instant in 1 minute and improve your conversion rate by 1%
https://instant.page
MIT License
6.01k stars 206 forks source link

intensity = "viewport" not working on Ajax Blog #101

Open giahylxag opened 2 years ago

giahylxag commented 2 years ago

I have a blog that load subsequent posts by an Ajax button. I have set intensity = "viewport", but new links are not automatically preloaded after Ajax update the content Any idea about a quick fix really be appreciated

dieulot commented 1 year ago

I’ll need to take a look at MutationObserver’s performance on big pages to get some clarity on how to handle that.

The most obvious way for instant.page to handle that would be to use MutationObserver, but I’m worried about the performance impact of it when observing the whole page.

Another way might be to use the upcoming scrollend event, set to ship in Chromium 114 on May 30th, which would apply after scrolling. This would not work when a web app add links without the user scrolling though.

The safest way would be to fall back to mouse/touch interactions for untracked links.

A developer-unfriendly way would be to provide a method to call on each DOM changes, such as instantpage.reapply().

The bruteforce way would be to call setInterval and check that every link present in the DOM (document.links) is tracked.