<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>22676</bug_id>
          
          <creation_ts>2013-07-15 23:11:18 +0000</creation_ts>
          <short_desc>APIs for page prerendering</short_desc>
          <delta_ts>2015-09-17 09:17:22 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>Needs Impl Interest</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ian &apos;Hixie&apos; Hickson">ian</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>annevk</cc>
    
    <cc>ian</cc>
    
    <cc>igrigorik</cc>
    
    <cc>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>90750</commentid>
    <comment_count>0</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-07-15 23:11:18 +0000</bug_when>
    <thetext>On Wed, 14 Mar 2012, Gavin Peters (蓋文彼德斯) wrote:
&gt;
&gt; We&apos;re having great luck in Chrome with &lt;link rel=prerender
&gt; href=foo&gt;. If that element with that rel attribute is in your
&gt; document, Chrome launches a hidden tab that we swap in and stitch
&gt; into history if the user navigates there. Navigation is as quick as
&gt; switching tabs, you either join an in-progress load or an already
&gt; loaded page, depending. It&apos;s really increased the number of 0ms
&gt; navigations chrome does! &quot;0ms: it&apos;s not just for about:blank any
&gt; more.&quot;
&gt; 
&gt; Right now, while Chrome registers and sends onload/onerror events to
&gt; link elements for prefetch, we don&apos;t do that for prerender.
&gt; Actually, it&apos;s a bit of a bug, but we always instantly send onerror
&gt; to rel=prerender link elements.
&gt; 
&gt; Hundreds of sites are using it now. Prerender instructions are also
&gt; sometimes inserted by GWS in results, which makes clicking on search
&gt; results faster. But I have some concerns:
&gt; 
&gt; 
&gt; *==First Concern: Timeouts==*
&gt; 
&gt; One concern we&apos;ve had feedback on from sites trying to adopt the
&gt; feature is maintaining prerender freshness. Right now, out of an
&gt; abundance of caution, we keep prerenders alive for a maximum of 30s.
&gt; That short limit has caused at least one site we know of to abandon
&gt; the feature out of frustration. While 30s may be a great timeout for
&gt; a search engine that wants to make sure you go to a fresh news site,
&gt; for instance, 30s probably makes sense. For a magazine or blog using
&gt; it for a next article, maybe they&apos;d be OK with the prerender being
&gt; around indefinitely, or some amount longer.
&gt; 
&gt; But this means we need more control at two places. Target sites
&gt; should be able to control the amount of prerendering done of them,
&gt; that&apos;s true. Today, though, I&apos;d like to talk about launching sites.
&gt; I think launching sites need a mechanism to cancel prerenders that
&gt; they&apos;ve launched, and also to specify to launch prerenders with
&gt; other than a short timeout.
&gt; 
&gt; 
&gt; *==Second Concern: Load Events/Statistics==*
&gt;
&gt; I&apos;d like sites using Prerendering to be able to track the
&gt; performance that this feature is getting them. We&apos;re in a good spot
&gt; on target sites for that today; we have implemented the visibility
&gt; API which exposes a visibility state &quot;prerender.&quot; The API has a
&gt; visibility change event, so a target site has relatively good
&gt; information they can collect.
&gt; 
&gt; But launching sites right now have nothing; they insert the link
&gt; prerender element, and that&apos;s that. Just like link rel=prefetch, I
&gt; think this event could return, just as a cross-origin iframe does,
&gt; onload/onerror/onabort (onabort for instance when we aren&apos;t
&gt; prerendering, or won&apos;t launch that prerender for some other
&gt; reason?). But that isn&apos;t quite there: there&apos;s lots of reasons that
&gt; the prerender could go away after onload. For instance, if a
&gt; prerender attempts to launch an XHR DELETE, we both don&apos;t complete
&gt; the request, and we drop the prerender. By this point, we&apos;ve already
&gt; fired off a load event at the page possibly, so if we send onabort,
&gt; that will be an onabort after onload, which I think is novel?
&gt; Although I guess &lt;audio&gt; can send abort many times, though it never
&gt; sends load, instead it sends the suite of media loading events.

On Mon, 9 Apr 2012, Gavin Peters (蓋文彼德斯) wrote:
&gt; 
&gt; Since sending the below message, I&apos;ve spent some time thinking about
&gt; how to handle the two cases I described in my initial posting,
&gt; timeouts and load events, and I think that both can be handled
&gt; inside of the existing markup framework on &lt;link rel=prerender...&gt;
&gt; elements.
&gt; 
&gt; Also, I forgot to include some documents in my earlier post; here&apos;s
&gt; Chrome&apos;s instructions to web developers for prerendering:
&gt; https://developers.google.com/chrome/whitepapers/prerender
&gt; 
&gt; Now, three weeks later here&apos;s an update on where my thoughts are on
&gt; the problems I introduced in my original email, along with my status
&gt; in addressing them:
&gt; 
&gt; 
&gt; *==Canceling Prerenders Using the Link Element==*
&gt; 
&gt; Some pages may want to keep the prerenders they launch fresh. A
&gt; search engine, for instance (like Google Web Search, which currently
&gt; issues prerenders) will not want users to navigate to stale
&gt; prerenders. The simplest way, and I think a way consistant with both
&gt; the current link element, and existing use of markup, is to cancel
&gt; the prerender associated with a link element when the link element
&gt; is removed from the document.
&gt; 
&gt; This is both similar to, and different from, the behaviour of other
&gt; elements when they are removed from documents.
&gt; 
&gt; It is different from what happens when an img element, for instance,
&gt; is removed from a document. Most browsers I&apos;ve tested informally
&gt; continue to load an img element even after it&apos;s removed from the
&gt; document; and this serves a purpose: inserting the same img element
&gt; into the document at a different location results in a seamless
&gt; continuation of the img load.
&gt; 
&gt; However, this is strikingly similar to two other cases: when a &lt;link
&gt; rel=stylesheet ...&gt; element is removed from the document, in WebKit,
&gt; we remove the stylesheet from the document, although this isn&apos;t
&gt; explicitly specified in 4.12.5.11,
&gt; http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#link-type-stylesheet.
&gt; 
&gt; It is also similar to what happens on removal of an object or applet
&gt; element. In 15.3.1 discussing the applet element, the state of a JVM
&gt; is discussed as dependent on insertion and removal from a document.
&gt; In 4.8.4, the object element specifically requires a plugin unload
&gt; when the object element is removed from the DOM.
&gt; 
&gt; 
&gt; *==Load Events/Statistics==*
&gt; 
&gt; The web visibility API[1][2][3][4] provides a great way for targets
&gt; of prerenders to detect prerendering. I&apos;d like launching sites to
&gt; have some means to detect some information about the prerenders
&gt; they&apos;re launching, to for instance gather analytics on if the
&gt; prerenders being launched are all going unused, which prerenders are
&gt; working best (keeping in mind that the current chrome prerender
&gt; implementation only allows one prerender at a time), etc...
&gt; 
&gt; For that, I propose we fire events at the link element; similar to
&gt; an iframe the standard load events load, error, abort, and possibly
&gt; loadstart. The abort event will be sent when the prerender is
&gt; dropped by the browser, for instance due to a timeout, or due to the
&gt; prerendered site doing an illegal action (i.e. XHR DELETE). These
&gt; events will allow a launching site to track uptake of target
&gt; prerenders, particularly in conjunction with &lt;a ping=...&gt; on the
&gt; relevant outgoing link.
&gt; 
&gt; 
&gt; *==Status==*
&gt; 
&gt; I&apos;m currently working on an implementation of the first part,
&gt; canceling, in WebKit &amp; Chrome, with some early architectural reviews
&gt; coming back in https://bugs.webkit.org/show_bug.cgi?id=82478 and
&gt; http://codereview.chromium.org/9875026/ .
&gt; 
&gt; [1] https://developers.google.com/chrome/whitepapers/pagevisibility
&gt; [2] https://developer.mozilla.org/en/DOM/Using_the_Page_Visibility_API
&gt; [3] http://ie.microsoft.com/testdrive/Performance/PageVisibility/Default.html
&gt; [4] http://www.w3.org/TR/page-visibility/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90809</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-07-16 17:38:49 +0000</bug_when>
    <thetext>On Wed, 7 Nov 2012, Gavin Peters (蓋文彼德斯) wrote:
&gt;
&gt; I&apos;m continuing to work on &lt;link rel=prerender&gt;, an API in WebKit,
&gt; implemented by Chrome, which allows applications to request pages be
&gt; loaded early for faster navigation. This is a leading cause of 0ms
&gt; navigations on the web!
&gt;
&gt; As we&apos;ve explored this feature, we&apos;ve continued to add to the API to
&gt; allow more applications to benefit from prerender, and measure that
&gt; benefit. At launch time, prerenders lasted 30s in Chrome before
&gt; being removed to prevent stale navigations. Now, the default is 5m,
&gt; in part because we use application removal of a &lt;link rel=prerender
&gt; ...&gt; element as a signal to kill the prerender, similar to the
&gt; &lt;applet&gt; or &lt;object&gt; element.
&gt;
&gt; I just wrote up a short proposal at:
&gt; http://wiki.whatwg.org/wiki/Link_prerender_events discussing the
&gt; next idea we&apos;re working on.
&gt;
&gt; By passing events to applications using prerenders, the applications
&gt; will better measure their use of prerender, and better control how
&gt; they are launched (serially or in parallel). The proposal has the
&gt; details.
&gt;
&gt; There&apos;s patches already in work to do this in WebKit and Chrome, see
&gt; https://bugs.webkit.org/show_bug.cgi?id=96474 for WebKit and
&gt; http://codereview.chromium.org/10918189/ for the embarrassingly out
&gt; of date Chrome version of this patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123223</commentid>
    <comment_count>2</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-09-16 09:55:25 +0000</bug_when>
    <thetext>Ilya, your work superseded this, right?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123231</commentid>
    <comment_count>3</comment_count>
    <who name="Ilya Grigorik">igrigorik</who>
    <bug_when>2015-09-16 18:30:09 +0000</bug_when>
    <thetext>Yes. There is more work to be done on it, but it should be handled in the RH spec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123238</commentid>
    <comment_count>4</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2015-09-17 09:17:22 +0000</bug_when>
    <thetext>This is now https://w3c.github.io/resource-hints/.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>