6

Since JSON shows a lot of benefits over HTML, why don't just abandon HTML? Qt frameworks with QML shows it is perfectly possible to use JSON to design rich content

EDIT:

Many of you think about this question in terms of performance vs html but i'm not about that.

HTML is just less readable and it's not enough per-se to describe UI behavior, look and feel. Maybe a technology shift is needed. I think from the developer point of view.

What about a browser capable of rendering a QML like web-page for example? QT with QML uses google V8 engine to do its work.

If you can write a web page in a technology that is not HTML, people will start using it. Browser could support HTML for a long time and allow developers to code with less stress

15
  • 6
    I have a better question. Why? Nov 6, 2014 at 16:13
  • 3
    What benefits did you have in mind? Expand on them please.
    – occulus
    Nov 6, 2014 at 16:14
  • 2
    legacy and inertia, 2 of the most powerful forces in computer development Nov 6, 2014 at 16:14
  • 2
    Another justification would be the horror that HTML represents as a terrible, cancerous spec that has not so much evolved over time as consumed the internet with the same relationship that Godzilla enjoys with Tokyo.
    – sea-rob
    Nov 6, 2014 at 16:23
  • 8
    JSON is a data interchange format. It is a category error to compare it with HTML. If you intend to use HTML DOM concepts and identifiers, implying HTML definitions for them, you are just referring to the serialization of HTML (the syntax used to linearize elements to a string of text). Nov 6, 2014 at 16:58

3 Answers 3

5

You are assuming JSON is always better than HTML, which is controversial at best (see MainMa's answer). But let's assume you're right. Why don't we get rid of HTML?

The surface answer is compatibility, but why is compatibility even an issue? The fundamental reason you can't make these kinds of changes on the web is because the web is a decentralized system built on communication protocols. So even if a majority of the web switched to JSON tomorrow, any cohort of the web still using HTML could function. There is no central switch.

3

While JSON has a benefit in terms of size (and so bandwidth) and simplicity (slightly easier to parse for smartphones), such major change of replacing one language by another would be too disruptive to justify the minor gains in bandwidth and performance. Such gains were maybe relevant ten years ago where mobile devices were very limited in terms of CPU and when many people had only access to low-speed internet, but today, it's much less relevant.

If you're not convinced, take an ordinary e-commerce website, measure the time spent:

  1. Downloading and parsing (sometimes minified and usually gzipped and cached on client side) HTML.

and compare it to the time it takes to:

  1. Download minified JavaScript source,
  2. Download images,
  3. Download CSS,
  4. Parse CSS,
  5. Render the page,
  6. Execute JavaScript.

Now, if you identified that after minifying HTML, gziping it and adding client-side caching, the loading and the parsing of HTML is still the bottleneck on your website, nothing forbids you, using current standards, to make a fully AJAX website, sending practically only JSON to your users.

3
  • 1
    "nothing forbids you, using current standards, to make a fully AJAX website, sending practically only JSON to your users" And then you have customers who don't want any javascript, just sayin ;)
    – Knerd
    Nov 6, 2014 at 16:33
  • I don't care about performance, i look at this from the developer point of view. Today web programming is very messy Nov 7, 2014 at 14:44
  • The question is not about HTML vs dynamically constructing a webpage using JS + JSON, it's about moving from HTML to JSON as the language parsed by browsers. Nov 13, 2019 at 13:00
1

Because the change would bring more pain than benefit.

Let's assume that you are right and that JSON is better than HTML for the job of defining web pages. Well, okay, but that's not enough to justify the change. There would have to be tangible benefit. Maybe raw web pages would be easier to maintain and quicker to download -- but we mostly don't edit raw HTML anymore, and download time is mostly about server load and media size.

On the other hand, the cost of change would be horrific.

Sorry to be cynical, but there (IMO) you go.

3
  • I would disagree here. You make it sound like it is either HTML or JSON. Which it isn't. There is a reason for doctype. We could easily declare json as a doctype and use both. We just need a way for the browser to parse it and apply css to it. This of course may require some changes, but the change would be far from horrific. Arguably many websites already do this, but with a round about way from using html templates rendered from json. We would simply be saving a step. While the bandwidth from the initial load, but the reduced file size for rendering templates. Mar 2, 2021 at 14:54
  • @DillonBurnett -- OPs question said "replace". Not use alongside.
    – Andy Jones
    Mar 3, 2021 at 17:22
  • I know. I'm not saying that 1 webpage can use both. What I'm was trying to explain is that you could have 2 different standards. Older websites can still use traditional HTML and new ones could use JSON. The browser should be able to tell them apart from the doctype. Just like it does with HTML and XML. Apr 5, 2021 at 14:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.