W3C home > Mailing lists > Public > public-web-perf@w3.org > February 2013

Re: Beacon API

From: Steve Souders <souders@google.com>
Date: Mon, 18 Feb 2013 11:39:40 -0800
Message-ID: <CA+hp-_ugqEUVs_9uMcxdcpna0nzLFSYpjqH7mAJ69fiBXUKHtg@mail.gmail.com>
To: Andy Davies <dajdavies@gmail.com>
Cc: Maciej Stachowiak <mjs@apple.com>, ifette@google.com, Anne van Kesteren <annevk@annevk.nl>, Web Applications Working Group WG <public-webapps@w3.org>, "public-web-perf@w3.org" <public-web-perf@w3.org>
That's great advice. Thanks, Andy!

-Steve

On Sun, Feb 17, 2013 at 2:12 PM, Andy Davies <dajdavies@gmail.com> wrote:

> On 16 February 2013 05:25, Maciej Stachowiak <mjs@apple.com> wrote:
>
>>
>> BTW as far as I know the best current nonblocking technique to phone home
>> on unload is to create an <img> in your unload handler pointing to the ping
>> URL, this will result in reliable delivery without blocking at least in IE
>> and WebKit-based browsers. I've found it hard to convince even knowledgable
>> web developers to use this technique or <a ping> over synchronous XHR, even
>> sites that are otherwise willing to do Safari-specific optimizations. I am
>> not sure why sync XHR in unload is so tantalizing.
>>
>>
> I asked Phillip Tellis (creater of Boomerang) about this and his
> experience is: (copied because he can't post to the list)
>
> "A beacon may be sent using a GET request via an Image object in a
> listener for either the onunload,the onbeforeunload or the onpagehide
> events.  No browser blocks if this is sent via the onbeforeunload event,
> however Opera does not support this event.  Firefox is the only browser
> that blocks for Image requests in the onunload event.
>
> Additionally, attaching a listener to the onunload event affects Page
> Cache in most browsers, so one should avoid that in any event.
>
> The solution we've come up with for boomerang (a general purpose beaconing
> solution primarily used for web performance beacons) is to attach a
> listener to the beforeunload event and either the pagehide or unload,
> depending on which is available (pagehide is checked first).  The first of
> these events to fire sends the beacon out and removes the listener from the
> other.  This has allowed us to fire beacons on every page unload without
> affecting unload time and without beacon loss."
>
> Andy
>
Received on Monday, 18 February 2013 19:40:13 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 18 February 2013 19:40:14 GMT