Le 10/11/2013 21:13, Reitbauer, Alois a écrit :
> A bit late, but let me chime in here as well.
>
> Typically analytics beacons are set in the onunload or unbeforeunload
> events. However, analytics also sends data while a page is active.
> Typically you do this to avoid not getting data in case when the user
> would simply close the browser.
This is already possible with xhr. The only thing sendBeacon adds is
better scheduling for better battery use... and even that is arguable;
an implementation could decide to better schedule xhrs.
> You also need to think about about single page applications. Sending
> data on unload does not make sense in this case
This already works with xhr, no need for a new feature, except for the
battery saving bit.
For single page apps, sending analytics is sometimes coupled with
receiving server updates to do one round-trip instead of two; sendBeacon
would be inappropriate there.
> Personally it does feel a bit weird to have a functionality like this
> attached to an event rather the navigator object.
This idea was conditioned on the idea that sending beacons is already
possible with xhr and that a more generic feature could emerge to
schedule all network requests more efficiently (battery-wise or else).
I imagine beacons aren't the only battery killers; I feel this problem
deserves its own solution. What do others think?
David