As the volume of data increases, pagination becomes an integral part of software development.
Instead of returning a huge chunk of data in a request, pagination divides and returns data to clients in smaller batches.
- Pagination & Infinity Scroll are two important techniques for the performance of the app.
- Using these techniques, you can get and display a small amount of data to reduce the network bandwidth and improve the performance.
Pagination:
1 - Data is Structured & hierarchy( you know how many pages are there)
2 - finite data.
3 - You can easily view the specific page(back or next button).
4 - The footer is accessible.
When to use Infinity Scroll?
- Data is real-time, dynamic & irregular.
- It is addictive (social media sites). Users don't know how much they scrolled.
- The Friction to move from one page to another page is very low when compared to Pagination.
- mobile-friendly.
Cons for infinity scroll:
- Poor seo.
- You can't implement search functionality.
Pros :
- Good SEO.
Infinity scroll :
1 - Data is Structured( you don't how many pages are there).
2 - Infinity data(you don't know how many pages there are, the user is just scrolling).
3 - It is harder to view the specific page( scroll from bottom to top or top to bottom.
4 - The infinity scroll doesn't give access to the footer. Some kinds of designs need a footer to be shown, so you can't use Infinity Scroll.
Types :
Fronted pagination: browser level.
< 1 2 3 4 5 6 ... >
Fetch all the products(200000) at once(one API call) and store it on the redux store or local state and then display a few products. Display the remaining products using pagination.
Pros :
- Faster page navigation because no need to make any API calls.
- Fewer API calls and reduced server cost.
Cons :
- The initial load time will be high because the API will take a lot of time to get data and send it back to the client.
- High bandwidth because it is carrying a huge amount of data.