2

I'm creating an interactive report in the form of an HTML page that needs to be accessible offline. Which of these options would yield better performance?

  • Create all of the HTML in advance (via server-side scripting) and hide all of the "views" except for one (the landing page). When the user clicks on a menu item, hide the currently visible view and un-hide the view corresponding to their selection.
  • Include all of the data as JavaScript variables/objects. When the user selects something from the menu, use a templating engine like Handlebars.js to create the required HTML.

I've found other posts covering client-side vs. server-side rendering, but nothing specific to offline applications that won't be able to make calls back to the server to request specific data points. In my case, all of the data (ranging from several hundred to several thousand records) must be included in the HTML from the start.

1 Answer 1

1

I would send the data and templates to the client and render the HTML on the client for a simple reason - it would probably work much faster (that depends on your actual data of course).

First, the amount of data to transfer is usually much bigger if you pre-render the HTML on the server. Templates and raw data would be much smaller, so the application would load faster.

Second, the user might not need all the rendered pages. If only a part of pages was used, the resources to render all the pages on the server are wasted.

One more point - it should be easy to make the application to be completely server-less if everything is rendered on the client. You could ship the json file with the data along with application code and assets and in this case it can work without server at all (of course this is only a point if this use case is relevant in your situation).

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your response! If we take the server-to-client transfer time out of the equation and only consider the page load time once the HTML is running offline would templates/raw data still be faster than pre-rendering the HTML?
It's hard to predict what will be faster, you could fetch the data to client and then render everything at once, this way there will be no difference after that. The overall time will depend on whether server-side or client-side rendering is faster. But also, if you'll have many users, you'll take off load from your server by rendering on the client.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.