DEV Community

Discussion on: JavaScript Location.reload() 🔄

Collapse
 
linehammer profile image
linehammer

The reload() function takes an optional parameter that can be set to true to force a reload from the server rather than the cache. The parameter defaults to false, so by default the page may reload from the browser's cache. The true parameter forces the page to release it's cache.

The window.location.reload() will reload from the server and will load all your data, scripts, images, etc. again. So if you just want to refresh the HTML, the window.location = document.URL will return much quicker and with less traffic. But it will not reload the page if there is a hash (#) in the URL.