From the Firefox popstate
documentation:
Browsers tend to handle the popstate event differently on page load. Chrome and Safari always emit a popstate event on page load, but Firefox doesn't.
As epascarello says in his comment, initialize your variables in the load
event and everything should work in Chrome/Safari and Firefox.