<?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>23508</bug_id>
          
          <creation_ts>2013-10-14 20:44:23 +0000</creation_ts>
          <short_desc>Browsers want to know when a page&apos;s scripts have finished &apos;loading&apos;, even if the scripts aren&apos;t delaying the &apos;load&apos; event any more (e.g. they do computation on startup)</short_desc>
          <delta_ts>2017-07-21 11:00:27 +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>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</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>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>94704</commentid>
    <comment_count>0</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-10-14 20:44:23 +0000</bug_when>
    <thetext>On Wed, 24 Apr 2013, Robert O&apos;Callahan wrote:
&gt;
&gt; Context: https://bugzilla.mozilla.org/show_bug.cgi?id=863499
&gt;
&gt; Use-cases:
&gt;
&gt; 1) User-agents provide thumbnails of Web pages (e.g. desktop Firefox,
&gt; FirefoxOS and Safari do this). We want to avoid taking a thumbnail while
&gt; the application is incompletely loaded. The firing of the document load
&gt; event is not currently a reliable indicator since the application might
&gt; have ongoing load activities (e.g. IndexedDB transactions, Websocket
&gt; activity) that do not block the document load event.
&gt;
&gt; 2) User-agent has UI to distinguish pages that are in the process of
&gt; loading from pages that are fully loaded. As in use-case #1, relying on the
&gt; document load event as currently defined to transition the UI to the &quot;fully
&gt; loaded&quot; state may be inaccurate.
&gt;
&gt; Proposal:
&gt;
&gt; Give Web applications APIs to explicitly delay the document load event. In
&gt; particular, add a method &quot;document.delayLoadEvent()&quot; that causes the
&gt; document load event to be delayed until a corresponding
&gt; &quot;document.stopDelayingLoadEvent()&quot; method is called. Allow these to nest so
&gt; that the document load event is delayed until at least as many calls to
&gt; stopDelayingLoadEvent() have been made as there were calls to
&gt; delayLoadEvent().
&gt;
&gt; Alternatives:
&gt;
&gt; Applications can fake this already by triggering an invisible subresource
&gt; load of a URI that never returns any data and never ends, and cancelling
&gt; the load when they want to stop delaying the load event. That seems fragile
&gt; and ugly.

On Wed, 24 Apr 2013, Glenn Maynard wrote:
&gt;
&gt; This seems a bit heavy-handed.  For these use cases, it doesn&apos;t seem like
&gt; you need to delay the whole onload event, which would have tons of
&gt; side-effects on the page.  You could just tell the browser that you&apos;re
&gt; still doing things, without it having other script-visible effects.
&gt;
&gt; The particular API above makes it easy for calls to be mismatched in subtle
&gt; ways, which would be hard to debug. I&apos;d recommend doing this with an
&gt; interface:
&gt;
&gt; delay = document.delayCompletion();
&gt; ...
&gt; delay.finished();
&gt;
&gt; That way, you can simply call finished() anywhere your process can finish,
&gt; without having to worry about calling it too many times.
&gt;
&gt; (Failing to call finished() would probably have to result in the delay
&gt; being permanent, as if you missed a call to stopDelayingLoadEvent, so it
&gt; doesn&apos;t expose GC behavior.  I suppose that relying on GC here isn&apos;t as bad
&gt; as it usually is, if the effects of this are never exposed to script, but
&gt; it&apos;s still not great since it would require that GC always happen in finite
&gt; time.)
&gt;
&gt; Both of these APIs are effectively manual resource collection, though,
&gt; which makes me nervous.  It&apos;s not something the platform is designed for
&gt; (hence all the difficulty with blob URLs).  Something like
&gt; document.delayUntil(indexedDbTransaction) would be nicer...

On Mon, 29 Apr 2013, Robert O&apos;Callahan wrote:
&gt;
&gt; It needs to support being signalled by script. The application might, for
&gt; example, be waiting for some app-specific setup protocol over a WebSocket
&gt; to complete.

On Sun, 28 Apr 2013, David Bruant wrote:
&gt;
&gt; In the Firefox bug, roc suggested:
&gt;
&gt; &gt; let the app specify &lt;html loading&gt;, and remove the attribute when done. 
&gt; &gt; [...] use a mutation listener to detect its removal.
&gt;
&gt; This is delightful; my new favorite idea on the topic. We don&apos;t need anything
&gt; more.

On Mon, 29 Apr 2013, Aaron Boodman wrote:
&gt;
&gt; I think that there would be many uses for a mechanism that allows
&gt; developers to take part in letting the UA known when it is &quot;ready&quot;. For
&gt; example, we would use then when analyzing extension code server-side.
&gt; Another example would be systems that take screenshots of web pages for use
&gt; in browser start pages, or search results.

On Mon, 6 May 2013, James Burke wrote:
&gt;
&gt; Not using document load as the API target means also adding a
&gt; mechanism for a script that does want to wait for this new state to
&gt; detect if that state is in play. For the paired JS API, it implies
&gt; providing something like a document.appReadyState if the new event is
&gt; tied to some name like &quot;appload&quot;. For the html attribute approach,
&gt; detecting the attribute is probably enough.

This was a big thread, I&apos;ve only quoted a tiny subset of comments
above. The full thread is at:

   http://goo.gl/zjYcqh#msg110
   http://goo.gl/ra5sXV#msg55</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94705</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-10-14 20:46:48 +0000</bug_when>
    <thetext>On Mon, 13 May 2013, Kyle Simpson wrote:
&gt;
&gt; Increasingly, sites are doing client-side rendering at page load time,
&gt; which is breaking the (useful) functionality of being able to have a
&gt; #hash on a URL that auto-scrolls the page to make some element visible
&gt; after page-load.
&gt;
&gt; A perfect example of this problem is that most #hash URLs (as far as
&gt; scrolling) are broken on gist.github and github when viewed in recent
&gt; Firefox.
&gt;
&gt; https://gist.github.com/getify/5558974
&gt;
&gt; I am proposing that the browser throw a JS event right before it&apos;s about
&gt; to try an auto-scroll to an element with the #id of the #hash in the URL
&gt; (during a page&apos;s initial loading), called for instance &quot;autoscroll&quot;. The
&gt; purpose of this event is to simplify how a web app can detect and
&gt; respond to a URL having a #hash on it that would normally create a
&gt; scrolling behavior, even if the element isn&apos;t yet rendered for the
&gt; window to scroll to. That gist shows how you could listen for the event,
&gt; and store for later use which target-ID was going to be scrolled to, and
&gt; manually scroll to it at a later time.
&gt;
&gt; If you have an app that does client-side rendering where it can break
&gt; auto-scrolling, but you want it to work properly, you can of course
&gt; manually inspect the URL for a #hash at any point, but it&apos;s a bit
&gt; awkward, especially if you are already relying entirely on event-driven
&gt; architecture in the app, and you want to just detect and respond to
&gt; events. This &quot;autoscroll&quot; event will normalize that handling.
&gt;
&gt; Notice the polyfill code in the above gist shows that you can obviously
&gt; detect it yourself, but it&apos;s awkward, and would be nice if it were just
&gt; built-in.
&gt;
&gt; Additionally, having it be a built-in event would allow an app to
&gt; prevent the browser from doing unwanted auto-scrolling in a very simple
&gt; and natural way, by just trapping the event and calling
&gt; `preventDefault()`. Currently, there&apos;s not really a clean way to
&gt; accomplish that, if you needed to.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>94708</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-10-14 21:11:25 +0000</bug_when>
    <thetext>Further feedback from the thread that started with the e-mail in comment 1:
   http://goo.gl/rhjEI8#msg87

Note that that thread actually requested a different feature, but the behaviour requested in the first quote in comment 0 of this bug would also solve it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>109144</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-07-21 20:51:27 +0000</bug_when>
    <thetext>This could also be addressed by hooking into a dependency system, just have the browser expose the &quot;page is ready&quot; state as something you can block...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128754</commentid>
    <comment_count>4</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2017-07-21 11:00:27 +0000</bug_when>
    <thetext>If this is still desired, please file a new issue at https://github.com/whatwg/html/issues/new.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>