Skip to content

Commit

Permalink
Propose using pagehide instead of unload (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Feb 18, 2022
1 parent d51816a commit c79d8bb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -286,12 +286,15 @@ following script to your page (after loading ga-lite):

```html
<script>
window.addEventListener('unload', function() {
var terminationEvent = 'onpagehide' in window ? 'pagehide' : 'unload';
window.addEventListener(terminationEvent, function() {
galite('send', 'timing', 'JS Dependencies', 'unload')
})
</script>
```

Note that `'pagehide'` is [preferred](https://developers.google.com/web/updates/2018/07/page-lifecycle-api#the-unload-event) for modern browsers.

## FAQ

### Why does ga-lite error with Pingdom?
Expand Down

0 comments on commit c79d8bb

Please sign in to comment.