Generate final HTML in PHP or JS?

Asked

Viewed 142 times

4

What is the best way, the best performance, to generate the final HTML. Direct in server-side or receive the database data and generate the HTML in client-side?

In the development of my current application, I came across this doubt, by receiving the data from the server and then generating much of the HTML in Javascript.

  • 1

    It depends, roughly, if the HTML you refer to is the whole page, it is more worth generating on the server, now if you need to update only a part of the page after it has loaded, it is less expensive to update only the necessary part via AJAX.

2 answers

4


Manage on the server side. It is easier to trust that the server is fast than to rely on the client’s computer speed.

The client’s computer may be old, have little memory or other limitations you do not know. If another script on the page fails your page may get stuck.

Another aspect to take into account is SEO. If the site has no content without running JS then the content indexed by the search engines will be poorer.

0

It depends a lot on your need and the type of application you are creating.

I, in content generation, would use a lot of ajax if my application was a restricted area and did not need to index this content in google, for example.

Browser other questions tagged

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