Reload a page with JavaScript

javascript

Updated August 29, 2026

Call location.reload() to ask the browser to reload the current document:

<button id="reload" type="button">Reload</button>
<script>
const button = document.querySelector('#reload');
button.addEventListener('click', () => {
  window.location.reload();
});

Assigning a new URL with location.assign('/dashboard') navigates to another document, while location.replace('/dashboard') does not keep the current page in browser history. Use links or form submission for normal navigation so the action remains accessible and works without JavaScript.

A reload may use the browser's cache according to normal HTTP caching rules. The old location.reload(true) “hard reload” argument is not a portable solution. If fresh content is required, fix cache headers or add a versioned resource URL; do not append random query strings to every request without understanding the caching cost. Avoid reload loops triggered by code that runs on every page load.

Sources

related.

Ruslan Osipov

Ruslan Osipov

About the author