Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Create a way to preload pages #1819

Closed
toddparker opened this Issue Jun 13, 2011 · 9 comments

Comments

Projects
None yet
4 participants
Contributor

toddparker commented Jun 13, 2011

Consider adding the ability to flag links in a page for pre-loading which will make it easy to lazy load in the next logical page(s) in a screen flow so avoid seeing the Ajax loader. Implement with a data-preload="true" attribute on a link. The framework would parse a page for all links that have this attribute, load each page (avoiding duplicates) and initialize each as pages.

@ghost ghost assigned scottjehl Jun 13, 2011

Contributor

jblas commented Jun 13, 2011

This is one of the reasons why I separated out loading from changePage(). You can now call loadPage() with a flag that tells it whether or not to display the loading message. I think all that's necessary is a listener on "changepage" that scans for links and fires off loadPage() calls.

Contributor

dave1010 commented Jun 13, 2011

What about a link tag with rel="prefetch"?

<link rel="prefetch" href="page.htm">

jQuery Mobile could look for these, prefetch them and (optionally?) parse them to load in any other resources.

Contributor

jblas commented Jun 13, 2011

Of course some sort of queue would be involved, and we have to handle the case where we are in the middle of a load and the user just clicked on a link ... cancel the current queue and immediately load the page for the link.

Contributor

scottjehl commented Jun 13, 2011

I like the link[prefetch] idea. Maybe we could build on top of that with a support test to mimic the behavior in non-Firefox browsers.

Contributor

jblas commented Jun 13, 2011

So one question is can we allow for prefetching of rel="external" content ... since it already uses the rel attribute. Or do we only care about jqm pages?

Contributor

toddparker commented Jun 13, 2011

I think the main objective is pre-caching jQM pages within an Ajax environment. Are you asking if we'd pre-cache a link if there is a rel=external on it? I don't think we'd do anything but if a browser supports the rel="prefetch" that would happen natively.

Contributor

dave1010 commented Jun 15, 2011

Google have just introduced "Instant Pages" in Chrome, which is almost identical to this (except natively handled by the browser) and uses rel="prerender" instead of rel="prefetch". See the documentation for more details. I have a strong suspicion Google will push this out to Android devices in the future.

Contributor

scottjehl commented Jun 20, 2011

Nice find, dave1010.
Man, I'm not sure we want full pages to be pre-rendered. Pre-fetch is actually a lot more like what we need for this, since most of the time the jQM application logic is already loaded and we're just fetching markup.

Makes me wonder if we should consider going back to the data-prefetch attribute on anchor links...

Contributor

scottjehl commented Jul 6, 2011

So here's a branch that adds a simple data-attribute of data-prefetch to any anchors that you'd like to pre-fetch after pagecreate. It may not be the way we'll want to implement this in the end, but I'm posting it here for feedback and discussion. The advantage here (over a native option like the link[rel] in firefox) is that the prefetching is handled like other page loads in jQM, so the page div is found in the response, and appended to the DOM so that it's there for a page change.

Looking for your thoughts. Thanks!

e49e695

@scottjehl scottjehl closed this in a5d0a29 Jul 15, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment