W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2013

Re: Beacon API

From: Andy Davies <dajdavies@gmail.com>
Date: Sun, 17 Feb 2013 22:12:35 +0000
Message-ID: <CABbusAJvs7XUk7oCSM7RavmVroWsU_6A4oS3=8AwK=QdLQOo7g@mail.gmail.com>
To: Maciej Stachowiak <mjs@apple.com>
Cc: 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>
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 Sunday, 17 February 2013 22:13:04 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:57 GMT