mickyginger — 2011-09-26T17:07:57-04:00 — #1
There is obviously more than one way to skin a cat. Often the best approach is the most efficient, but how do you work out which is the most efficient way of getting form a to b?
This has cost me a lot more in terms of code bloat, but has saved on the ajax call.
But have I waisted my time? There will only likely be one or two end users for this application, and they will probably only each actually use it once or twice a week to add events here and there.
It seems I can either push the majority of the work load on to the PHP scripts and use the client-side language to just make ajax calls, or I can reduce the amount of ajax calls and give the client-side script more work to do. But I don't know which would be better for my application.
Does anyone have any advice or input on how the go about making these decisions.
marplo — 2011-09-29T10:40:52-04:00 — #2
My opinion is that it's better to have less php /ajax calls, and give the client-side script more work to do.
sdleihssirhc — 2011-09-29T11:51:59-04:00 — #3
Here's an answer on Stack Overflow that seems pretty relevant:
In theory, either would be acceptable. In practice, I would lean toward doing as much repetitious work on the server as possible. If you think about it in terms of which can do it faster, you KNOW how fast your server can do it. The resources stay (relatively) constant.
The safest bet is always to use known quantities as much as possible. In this case, the sever is your known quantity - do the work there.
But, here's an answer to a different question with another way to look at it:
For small number of clients, server side code is generally faster. For very large number of clients, offloading work to client side code can greatly improve performance.
But ultimately, I think the following comment on that second question is the most relevant:
It doesn't matter. Performance should be your last concern in web development. Make it secure, functional, reliable and maintainable first.
So it kind of looks like a gut thing (unless, of course, you have actual data suggesting one route over another). If it makes you feel dirty, then change it.