JSON performance to power an entire website

Asked

Viewed 338 times

7

Adapting a Drupal theme to pure HTML with a tight schedule as expected, the code came out a little more complicated than I’d like.

In this way, I had the opportunity to explore JSON and some of its functionalities and decided to create an archive data.json to feed all texts of the site and make it possible, in addition to the easy editing of these, in the near future to support other languages.

Follow JSON excerpt for analysis:

{"Textos": {
            "TituloDestaque":"Lorem ipsum dolor sit amet,",
            "CorpoDestaque":"<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>",
            "Sobre1":"<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>",
            "Sobre2":"<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>",
}}

This negatively affects the performance of a medium to large site?

The link I had access to test is brute, for lack of a better word, so I didn’t get a conclusive metric.

I’m talking about the order of 200~300 parameterized paragraphs in a JSON file called by 8~10 pages for medium sites and 750~1000 paragraphs on 20+ pages on large sites.

If it is not correct to solve in this way, what would be the option without using BD?

  • 1

    I believe that this will get Ruin for the clients, because the json will be processed by the browser and not by the server that would deliver everything ready, so the performance site would be low performance for less robust computers but download the server, it would be good to balance their work

  • 1

    @Felipefonseca now that I saw that it is a pure html site... considering that you have two options xml or json, and I think json really is the best option between the two...

  • 1

    http://www.ziggytech.net/technology/web-development/how-big-is-too-big-for-json/

  • @Filipe.Fonseca Code editing that improves readability without changing logic are welcome! I changed the code by breaking lines without altering the logic to avoid scrolling. See more on http://meta.pt.stackoverflow.com/questions/749

  • @But it changed the logic. My Jscript uses those markers, each one of them.

  • Read the @Gabe response

  • @Your link in the comments explains exactly what I would like. I ask you to please formulate an answer using it which will be a pleasure to accept it and +1.

  • 1

    @Filipe.Fonseca ah, right! I must have accidentally removed the transponders.

Show 3 more comments

2 answers

5


Since your site is pure HTML, I believe you don’t have much output.
According to this link, a JSON with about 1000 paragraphs (~700KB) should use about:
15MB in the IE
35MB in Chrome
200MB in Firefox

On an i7 the processing is in the order of tens of milliseconds on a Macbook Pro Core i7 2.2GHz. Since it was not said the profile of users (internal system x open, machines), I deduce that by the Brazilian average of the Pcs there are great chances of this value being multiplied. As there will be the transformation of paragraphs into JSON for HTML and they are parameterized, you will have more added milliseconds in page loading.

I suggest, load the JSON asynchronously and during loading give feedback to the user (for example "Loading content..."), not to lock the page to the user and inform him that content that is not visible at first glance is in the process of loading.

I still suggest, that you make a load on demand (much used nowadays), Facebook "Timeline" style. I don’t know if it will be possible in your layout, but the hint is to initially load the first few paragraphs - or enough content to occupy a screen and the user while loading the rest. And then load the others successively as the user scrolls the page (on demand) or in sequence same in the code.

  • I believe that to decrease the load I will have to separate in several files, one for each page instead of loading 700kb in one shot. As for the feedback, perfect, it was exactly what I was looking for.

  • 1

    Yes, and press successively.

1

  • It looks promising! I’ll take a look at it calmly.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.