DEV Community

Discussion on: JavaScript and manipulating the DOM

Collapse
 
alainvanhout profile image
Alain Van Hout

There are a number of reasons why a browser request is preferable to a page reload:

  • a reload can lead to a page flash (or worse). For micro-interactions, that would be very annoying
  • a reload causes substantially more network traffic (even if some resources can be fetched from the browser cache)
  • a reload recomposes/rebuilds the page from its resources (html, css, images, ...) and inherently causes a full redraw of the page, even if e.g. only the ❤️has changed
  • a reload discards the previous page, which means that those system resources need to be cleaned up, and that they remain unavailable until that has been done

Aside from those pragmatic reasons:

  • A reload does not respect separation of concerns, since you essentially have a god-method that Does All The Things(TM) rather than confining itself to the necessary scope (such as reacting to a ❤️click).