I have a JS application, which communicates with the server only by API calls. All the data for the app is recieved via API calls. Is it better to sort table-like data on client side (js), or server side (PHP/MySQL) ? Is it possible to sort reliably with js ? I'm keen to sort on client side, but not sure if this reliable enough.
-
I would think that depends heavily on the number of records you are dealing with.Henning Glatter-Götz– Henning Glatter-Götz2012-05-11 14:48:43 +00:00Commented May 11, 2012 at 14:48
-
@hglattergotz I have a lot of recordsVitalii Lebediev– Vitalii Lebediev2012-05-11 15:01:48 +00:00Commented May 11, 2012 at 15:01
2 Answers
You can sort on client side. But it is not efficient if you have a lot of data. In this case you need to provide some pagination mechanism and it makes no sense to sort paginated results clientside.
The answer from me: use server side sorting if you have A LOT of data (hundreds of records may be an indication, but look what works for you). Otherwise load all the data using api call and sort client side.
Comments
While you can on the client side, why not sort them first on the server side? Take advantage of MySQL sorting. This avoids unnecessary processing on the client side, especially on low-powered machines (netbooks and mobile).