开发者

Performance difference between static HTML rendering and dynamic DOM element rendering

I am building an online survey app. I am rendering questions over several pages. I am going to use an Ajax approach, where a container div is updated with the next question as the user pages through the survey. The question开发者_Python百科s will be stored on the server. Should I return a fully formed HTML fragment from the server, and set the div html directly, or should I return a JSON object representing the questions and some dynamic DOM manipulation on the client to render the HTML into the div? I am keener on the dynamic approach, but wondered if there might be a performance issue when running on an iPad (having seen poor jquery performance on an iPad in the past).

Thanks very much.


Unless you're doing something absurdly odd you'll never notice any performance difference between the two. You may, however, sometimes notice a difference in bandwidth since the generated HTML will certainly be much larger than any structure passed down.

Either way, the biggest deciding factor should be whether you want to generate the structure on the server or client. My vote is always on the client :)


I've had issues in the past with slow internet connectivity and making my ajax scripts not functional or extremely slow, so the user ends up waiting for the data to be sent to the server and then once sent, display the next question.

I would personally opt for the fragmented full HTML. So that the user can quickly go through the survey without waiting for the server to load the AJAX. Therefore increasing his go through rate. At the end, send the completed survey.

I hope this helps.


I'd keep my view and my data separate. On top of that, transferring data is usually cheaper.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜