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