A 2 minute read written by
Nicolai August Hagen
Did you know that you can reload the current webpage in over 500 different ways?
Many years have passed since your (grand) parents surfed the web with Netscape Navigator, or Internet Explorer was actually used by the people of the web. Browsers have not always had the same version, and neither have the various web standards.
Reloading the window in JS
10 randomly picked examples
location = location location = window.location['href'] window.location.assign(location) window.location.replace(location) self.location.replace(location) location.href = location self['location']['assign'](window['location']) location['reload']() self.location['href'] = self.location.href self['location']['href'] = self.location
This is simply insane!
Or, you could go for the even crazier approach:
(hint: run it in the console)
location.href = location versus
location['href'] = location
where both snippets in practice does the exact same thing.
Discussing which one of the 500+ ways to reload is the best is like discussing wheter you should use Emacs or Vim, or Flow or TypeScript. The most important thing, I guess, is readabiliy - making sure you and all co-developers understand.
So perhaps not the