JavaScript article thumbnail image.

How do you programmatically reload or refresh the current page using JavaScript?

JavaScript has a built-in way to get this information using the Location API interface, which represents the location (URL) of the current web page you're located on. The global Window interface has access to the Location object that can be used via window.location.

Using that interface, you can reload the page with the location.reload() function:


That function will reload the current URL, just like the refresh button would do in a browser.

You can test this by opening the developer tools in your favorite browser and call the window.location.reload() function in the JavaScript console. It will force the current page to reload.

For more information on the browser support for this method, see its MDN web docs page.

Thanks for reading and happy coding!

About the author

Hi, I'm Nick Major. I'm a software developer from Wisconsin, United States.

I create free and premium courses, have published hundreds of informational coding articles, and am currently a Frontend Software Engineer at RoundingWell.

You can read more about me here.

Picture of Nick Major.