I have a design question. I have a website where users enter short messages and they are displayed to other users. Sometimes these messages have formatting in them so I need to manipulate strings. I can do this either on the server or on the client. My question is where should it occur?
If it happens on the server then there’s more of a load on the server as well as more data to push to the client. However, the server machine will usually be a “better” machine than what the users have.
If it happens on the client the string manipulation gets offset to the users but I’m not sure how efficient javascript/jquery string manipulation is.
Any thoughts on this?
Well I am not sure how you are getting this string to the other users but I am assuming you sending it back to your server anyways so the question is, should you get it clean on the client and then send it to the server or just take whatever you get and clean it on the server.
If you can guarantee javascript is enabled then offloading it to the client would really cut down a lot of extra mini processes on the server with each call and distribute that load to the client which is great.
Things to consider… if you do it just in javascript you have no guarantee of what you are getting since you are not checking / cleaning the string on the server. This could be dangerous depending on how you are sending this information to other users. Just think of javascript injection attacks.
If you do it on the server then you don’t really have to worry about it because you can guarantee what you are sending out is exactly what you want instead of just passing through whatever and hoping the javascript on the client has you covered.
Are you really doing so many transactions that the string manipulation is that much of a factor compared to whatever other operations you are doing with each message server side?