Shahin

Event Queue / Buffering

Advanced
Updated Jul 11, 2026 Shahin editorial 2 min read
PronunciationEN/ɪˈvɛnt kjuː ˈbʌfərɪŋ/

Event queue buffering is the library holding events instead of making one network request per event, then delivering them in batches.

The queue drains on three triggers: a flush interval, a batch size threshold, and the moment the visitor leaves the page or app. When the queue is persisted to device storage, unsent events survive the next page load or app launch, and failed deliveries are retried with growing backoff. The trade-off is explicit: larger batches mean less battery use and fewer requests, but a wider window in which an abruptly closed tab swallows data. Two things are routinely forgotten: the last event before exit only arrives if it uses a transport that survives page teardown, and each event carries the state captured when it entered the queue, not when it was sent.

Sources:MDN — Document: visibilitychange event