0

All I want to know, is there any difference in the speed of a mechanism that returns the whole HTML as the response of an ajax request and a mechanism that returns a array as json and makes the HTML via JS coeds ?

Currently my website makes the whole HTML once on the server side. And use it both for http and ajax requests. It works as well, but since I like perfection things, I want to know, if I change my current algorithm and make the HTML on the client side for ajax requests, then the speed will be better?

stack
  • 10,280
  • 19
  • 65
  • 117
  • 1
    I'd say "it depends" – Jaromanda X Apr 24 '17 at 05:35
  • @JaromandaX Depends on what? – stack Apr 24 '17 at 05:35
  • on your particular site - I guess it's too much of an investment of your time to test for your particular site though – Jaromanda X Apr 24 '17 at 05:37
  • On the speed of the connection (typically the JSON will be smaller), the speed of the client-side processor (returning JSON and formulating it client-side is more work for the client), server load, the exact nature of your structures, time of day, whether it's Tuesday, wind direction... Okay, I got a bit frivolous there, but what it comes down to is: It's unlikely to really matter, and if/when it starts really mattering, worry about it then. – T.J. Crowder Apr 24 '17 at 05:37
  • @T.J.Crowder You know, I have no time to spend on this case. My website is a *start-up* project and I want to launch it as fast as possible. Because I've some competitors. I mean if I want to change the algorithm of my website (making the HTML on the client side), it takes almost 1 week. So is doing this that much important? if so, then I have to do that, but if returning the HTML by server side isn't a big problem, then tell me ..?? hum? What would you do if you were instead of me? – stack Apr 24 '17 at 05:44
  • It depends on too many factors specific to your situation. Jaromanda was really right, it depends. For instance, if it were **me**, I'd do it client-side, but that's because I'm a really client-side guy and experienced with lots of client-side tools for doing this, which doesn't really help you make a decision for *you*. :-) – T.J. Crowder Apr 24 '17 at 05:46
  • @T.J.Crowder I'm a client-side guy too .. not as much as you but I am `;-)` ..! You know, there is also another problem: in your case, I have to make the HTML twice .. one time on the server-side *(for HTTP requests)* and one time on the client-side *(for Ajax requests)*, which it makes developing harder ..! Right? Just tell me, How much the speed will drop if I return the HTML as the response of an ajax request? *(than returning just a array as json)* – stack Apr 24 '17 at 05:50
  • @T.J.Crowder Noted that, the whole response as HTML has this size: https://i.stack.imgur.com/D5NkF.png ..! Also the second note is the internet speed is too slow in Iran *(my country)* – stack Apr 24 '17 at 05:52

0 Answers0