1

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.

2
  • I would think that depends heavily on the number of records you are dealing with. Commented May 11, 2012 at 14:48
  • @hglattergotz I have a lot of records Commented May 11, 2012 at 15:01

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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).

5 Comments

The reason I wonder is that sorting on server side means making additional API calls to retrieve sorted data.
@Malgin how can one call to sorted data be additional? can you show us the API? maybe the API needs some redesign.
by additional I mean separate call to get sorted data. API call look like GET /content - retrieves all content If I unserstand correctly, separate call whould be GET /content?sort=<field_name>
yes, something like that. if your API has sorting, then just add the sort parameter. otherwise, modify that API to support it.
but separate call will be required. Ok, thanks, will think it out

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.