Created
November 1, 2017 17:47
Short demo using window.performance.navigation to determine whether page was reloaded
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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