Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sorting with javascript or with Server Request? [duplicate]

Possible Duplicate:
Sorting on the server or on the client?

As a part of a project for my university, I have to make a website like a forum let's say.

So there will be posts, many of them. Every Post has a like bar, comments, some text, some buttons etc. Also the user will be able to sort these posts that appear in a page, based on some criteria like date,name, popularity etc.

My question is how should I implement the sorting: 1. with javascript on the browser's side, or 2. with a form or something, and a new request to the server (in this way the server has to send me back the posts sorted) ?

Thank you in advance.


1 Answers

There are pro's and con's to both.

Generally speaking, if you already have all of the data available in the client anyhow, you will provide a more responsive user experience sorting on the client.

If you have to fetch extra records that you would otherwise not fetch to sort client-side, there's a great chance that you are bloating the download to the client beyond the optimal point, and a sort on the server-side via Ajax would be better.

like image 176
Eric J. Avatar answered Aug 06 '26 23:08

Eric J.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!