Why do Discourse forums require JS?

This deserves some elaboration.

For a start:

:thinking: :eyes: GitHub - discourse/discourse: A platform for community discussion. Free, open, simple.

image

Discourse is actually mostly Ruby on Rails, and (according to GitHub) only a quarter of it is javascript, though it’s an extremely critical quarter and dominates the client side.

The reasons why Discourse and other modern websites(/webapps) use Javascript are:

  • workload: relieves the server from a lot of work so helps the website scale better (hey, get the users machine to share some of the work, why not?!)
  • bandwidth: although the initial load might be slightly longer to bring down that javascript, the interstitial loading of data from then on is MUCH faster using FAR less bandwidth (if the world lost javascript tomorrow, the internet would possibly grind to a halt?), because you only have to transfer the data and not all the markup and layout of all the UI. So things get done over the web so much quicker and enables low bandwidth connections like bad mobile connections.
  • UI: improves the dynamic nature of the UI so the user experience is better (e.g. click a button to update only a portion of the screen - no big whole browser repaints).
  • its a standard: Javascript is a standard on all modern browsers, including mobile ones so it’s write once and bring app like qualities to the majority of devices.
  • separation of concerns: decouples the server processes from having to worry about rendering the UI (usually) so easier to migrate to or support other front ends that may not be javascript (or even HTML) based. iOS app, anyone?

I’m sure there are plenty of other advantages but those are the basic ones.

12 Likes