How to reload current page with Javascript?

If you mean just reloading the current page, you can easily do it in Javascript with the reload() method of the location object.

window.location.reload()

This will cause the browser to display the current page again, reloading the page you are currently on.

The only detail you should know is that the browser can activate the cache, in fact it would be normal, so it is possible that certain parts of the page do not update even if you do a reload. Although this already depends on the browser and also on the configuration of the user who is accessing.

If you want to be sure that you avoid the browser’s cache, you can do various things, the easiest would be to put a query string at the end of the URL and also make it random.

Thus, instead of reloading the page (for example) example.com what you are going to do is tell the browser to navigate to the address example.com?random=2237746287

By passing the query string at the end you are literally going to a page with a different URL, so it won’t be caught from the cache.

Then the reload() method of the location object no longer works for you, but you would have to perform the reload in a slightly more traditional way. If you are interested in this possibility, this article may be worth it. Or at least do something similar to what you propose.

Loading Facebook Comments ...
Loading Disqus Comments ...