How to Reload a Page With the Window Reload Event in JavaScript

To reload a webpage with JavaScript we need to use the Window Reload Event.

Reload page with a single line of JavaScript:

Paste this code into your browser Console and hit enter


Cool, but perhaps not so practical? Let’s try something else.

Reload page with a button click event:

Add this to your HTML markup:

<button onclick="reloadPage()">Reload page</button>

Add he window reload event function this to your JavaScript file

function reloadPage() {

Note: the window reload event doesn’t work inside the CodePen editor, but you can test it out in CodePen’s debug mode.

Has this been helpful to you?

You can support my work by sharing this article with others, or perhaps buy me a cup of coffee 😊


Share & Discuss on