Don’t break the web or why html is important

I am a member of the advanced WordPress facebook group and its seems every few days someone posts and article on there waxing lyrical about the latest javacsript only theme they have built using the latest JavaScript framework and the rest api.

Dont get me wrong, I love javscript, and I think the rest api is one of the best things to happen to WordPress but every time I read about someone usea front end framework to build a theme I shake my head.

A wise man once said,

just because you can doesn’t mean you should

This applies to so many things, especially JavaScript when used to output content.  In order to explain we all need to be reminded of the way the web is traditionally designed namely:

  • HTML for con­tent
  • Css for pre­sen­ta­tion
  • Javascript for func­tion­al­ity

This combination might seem old hat but it was created by smart people with good reasons.

When done properly it has three major strengths

  1. It conveys meaning
  2. It is robust
  3. It has a clear separation of concerns

However it can be slow so today many advocate using JavaScript to interract with apis to replace this traditional paradigm. This has  major advantage in that can be substantially faster as the client side javascript can request only the information that it needs. However it also means that javascript is now the creating the content as well as the providing the functionality

However lets just compare how this compares to the traditional approach. Namely:

Conveying meaning.  Yes javascript can convey an experience that may be indistunguishable to the eye BUT the web is not just a visual medium for humans. Machine like search engines, and screen readers are important and in most cases a javascript front end is invisible to these agents

Being robust. Javascript is a not a fully standardized lanaguage and is notorious for conflicts and errors, and being browser depe3ndent. So an error on a javascript front end usually means the whole site falls over. In contrast a traditional semantic html front end degrades gracefully

Separating concerns. In a JavaScript front end you are tightly coupling functionality with content and potentially presentation as well. This actually if you change the api or you change your javascript the whole thing falls over. In contrast html is html and if the JavaScript stops working you still have the html.

Javascript is important but its not a replacement for html. Its future is in rproviing functionality, both in enhancing the reading experience and in making the eually important area of creating, updating and deleting content on the web.

Finally I’d like to urge you that is you need speed work on the basics like http caching, or look to modern technologies like http/2 and service workers.

Fill in your details below or login