Pagination: Server Side or Client Side?

jrutter picture jrutter · Jan 2, 2009 · Viewed 29.5k times · Source

What is it best to handle pagination? Server side or doing it dynamically using javascript?

I'm working on a project which is heavy on the ajax and pulling in data dynamically, so I've been working on a javascript pagination system that uses the dom - but I'm starting to think it would be better to handle it all server side.

What are everyone's thoughts?

Answer

Cory House picture Cory House · Jan 2, 2009

The right answer depends on your priorities and the size of the data set to be paginated.

Server side pagination is best for:

  • Large data set
  • Faster initial page load
  • Accessibility for those not running javascript

Client side pagination is best for:

  • Small data set
  • Faster subsequent page loads

So if you're paginating for primarily cosmetic reasons, it makes more sense to handle it client side. And if you're paginating to reduce initial load time, server side is the obvious choice.

Of course, client side's advantage on subsequent page load times diminishes if you utilize Ajax to load subsequent pages.