Skip to content

Instantly share code, notes, and snippets.

@ayamkv
Created June 12, 2021 08:20
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 ayamkv/48145c60e1ea7646c26d1589a9caf195 to your computer and use it in GitHub Desktop.
Save ayamkv/48145c60e1ea7646c26d1589a9caf195 to your computer and use it in GitHub Desktop.
Simple ReplaceHistoryState
function docReady(fn) {
// see if DOM is already available
if (document.readyState === "complete" || document.readyState === "interactive") {
// call on next available tick
setTimeout(fn, 1);
} else {
document.addEventListener("DOMContentLoaded", fn);
}
}
docReady(function() {
history.replaceState({}, null, "/")
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment