Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How much formatting to perform on the client in Javascript

Posted on 2013-12-25
3
Medium Priority
?
394 Views
Last Modified: 2013-12-26
I'm rewriting a 2005-era ASP.NET app that currently does most of the display formatting on the server by building HTML strings which are then sent via xmlhttprequest to the client.  

I can see how I might use MVC/Razor/JQuery/JSON/AJAX to just send the data content to the client, and let the client do the DOM display object construction, even if it requires a good bit of business logic.

> At the moment I'm not overly concerned about exposing the IP of the display logic in the client javascript.
> For this application a "large" completely formatted div in the app might run 500K of HTML of which no more than 50K of data would be data (average would probably be more like 250K and 25K).   There could be three such divs being displayed (overlapping) at any one time (along with a few much smaller ones, essentially popups).
> I'm hoping to run the app on PCs, tablet and phones.

What I'm hoping to find from EExperts is:
==> input/ideas/views on how to decide whether to put the display logic in the client, or keep it back in the server.

Any help with this would be appreciated.

Thanks.
0
Comment
Question by:codequest
3 Comments
 
LVL 27

Assisted Solution

by:Chinmay Patel
Chinmay Patel earned 900 total points
ID: 39739633
Mostly if it is not business critical or security related, I prefer to build display on client side leaving my server free to do what it is meant to  do : Serve(the server side content and execute server side logic).
0
 
LVL 18

Accepted Solution

by:
Gary Davis earned 1100 total points
ID: 39740801
I'd recommend returning the data in JSON format which is native to javascript and then using a templating solution to format and iterate thru your data. A popular Template technology is included in Knockout.js. See How to Use Templates in Knockout.js.

Gary Davis
0
 
LVL 2

Author Closing Comment

by:codequest
ID: 39741030
Thanks for the input.  Those are clear recommendations for separation of concerns and a pointer to a tool that indicates client side formatting is best practice.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.
Suggested Courses

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question