Skip to content

Instantly share code, notes, and snippets.

@conorgil
Created November 1, 2017 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conorgil/da0f931c23d35eede0033e261bc7e7e6 to your computer and use it in GitHub Desktop.
Save conorgil/da0f931c23d35eede0033e261bc7e7e6 to your computer and use it in GitHub Desktop.
Short demo using window.performance.navigation to determine whether page was reloaded
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigation
// https://blog.chromium.org/2017/09/chrome-62-beta-network-quality.html
// https://stackoverflow.com/questions/46226144/window-performance-navigation-type-works-in-ie-and-firefox-but-not-in-chrome
// This demo works as of 2017-11-01
const TYPE_RELOAD = 1;
function isReloadedPage() {
return performance.navigation.type === TYPE_RELOAD;
}
function main() {
if (!isReloadedPage()) {
console.info('This page WAS NOT reloaded.');
} else {
console.info('This page WAS reloaded.');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment