Ad

How To More Efficiently Generate Large Amounts Of HTML

I have a web app running off google apps script, when a user searched for some data I generate templated HTML on the server and return that to the client which populates a table (Each table row is an accordion that expands down for much more detailed info for each item).

The problem is that the HTML generation takes ~20 seconds if the user does a search that returns all data. It returns ~3.5MB of HTML to the client.

I was trying to utilize JQuery templates, but each row may contain different data and that format of that data may change periodically, I had more templates than I did web page. It's not really maintainable to manage a ton of JQuery templates when 15 lines of code (As a "Scriplet") on the server can create the same HTML.

So my question is, how can you serve a large chunk of data to a client and generate HTML without relying on templates for each data format?

If this is not descriptive enough, please let me know.

Ad

Answer

The problem is that the HTML generation takes ~20 seconds

Generate HTML on client side. server only return data .

if the user does a search that returns all data. It returns ~3.5MB of HTML to the client.

Do not return all data at a time, just return a smallest information. like how many page , category, etc. When user select a page , client send a request to get details from server.

Ad
source: stackoverflow.com
Ad