I always thought about that button that says “Load more…” because, the user needs to wait when he pressed it. So i thought, since the user cannot jump 9 pages forward, why not preload the next page? So when the user clicks load more, the application would instantly display the next page content, and while the user browses through it, the application loads the next page and so on.
What do we we want to achieve?
One thing i always though would improve the User Experience on Twitter and Facebook was the pagination.
Basically, i always thought about that button that says “Load more…” because, the user needs to wait when he pressed it. So i thought, since the user cannot jump 9 pages forward, why not preload the next page? So when the user clicks load more, the application would instantly display the next page content, and while the user browses through it, the application loads the next page and so on. Since websites like Facebook and Twitter load not too much data per request via the “Load more” button, i assume its pretty safe to preload content.
Smart Scrolling Pagination – A jQuery plugin
So after searching on google for something like this, i thought to myself that i might as well learn how to create a jQuery plugin. And here it is: a very very (really!) simple to use plugin that will help you achieve what Twitter and Facebook should do (in my opinion). The plugin is not perfect, it can be enhanced with more cool stuff, but i believe it is good for a basic usage (until next versions).
How to use
Simply include the jQuery library and the plugin into your page and call it like this:
$(".content").smartPagination({
url: "result.html",
button: "load_more_content"
});
where the url is the path to your script that will generate the content to be loaded and button is the id of the element that will trigger the loader when clicked.
Advanced usage (no really)
If you want a list of all the options, here it is:
$(".content_extended").smartPagination({
url: "result.html",
parameters : { "isAjax": false },
method : "get",
debug : false,
button : "load_more_content_extended"
});
where parameters is a Json object containing all your parameters to be sent to the url, the method can be either get or post and debug can be either true or false.
If debug is set to true then you will get alerts with each step the plugin does so you can see what happens at any time.
Conclusion
Here is what i plan to do in the near future for this script:
- Add options for effects (currently only fadeIn() is supported)
- Add options for receiving from the “url” only a Json element and to allow the developer to parse it as he considers
- Add options for automatically adding content (at the top or the button) based on the “url” – something like jQuery Spy
If you want more features added to the TODO list then please share them below!
And in the end, if you liked the plugin please share it so everyone can benefit of of it !


