popstate

Listen on popstate history events with Safari compatibility

Usage no npm install needed!

<script type="module">
  import popstate from 'https://cdn.skypack.dev/popstate';
</script>

README

popstate Build Status

Listen on popstate history events with Safari compatibility

Old versions of Chrome and all versions of Safari emit popstate events on page load (MDN). popstate defers registration of the event listener to avoid double-calls.

Install

$ npm install --save popstate

Usage

var popState = require('popstate')

popState(function (event) {
  //=> popped state  
})

API

popState(callback) -> undefined

callback

Required
Type: function

A callback to safely register for popstate events.

License

MIT © Ben Drucker