user776942
user776942

Reputation:

infinite scroll - how do twitter facebook "hide" extra data

I've been reading and trying to implement various forms of infinite scroll, whether it be in jquery, django, or some combo of both. I'm using the firebug extension in chrome to track the calls made when I scroll to the bottom of the page and request more data from my database. Whenever I hit the bottom of the page, firebug shows an additional request to grab more data.

Using firebug on twitter.com and facebook.com, I noticed that no additional requests show up in firebug when I use their infinite scrolls and scroll to the bottom of the page, even though more data is loaded. I imagine this is much better from a security standpoint. How do they do "hide" those additional requests?

Upvotes: 2

Views: 465

Answers (3)

DaveR
DaveR

Reputation: 2483

The extra content isn't hidden - in Facebook, when you approach the end of the page an ajax call is made to get the new content.

Looking at the resources in Chrome a call is made to this file to load the extra contents -

https://www.facebook.com/ajax/pagelet/generic.php/MoreStoriesPagelet

Upvotes: 1

Robin Maben
Robin Maben

Reputation: 23054

They don't hide it. They do fetch the extra data on an on-demand basis


Possible approaches you could look into are :-

  1. Tracking the scroll event to see if user has reached the end of scroll.
  2. Track when the footer(or similar div at the bottom) comes into view.

Upvotes: 2

topless
topless

Reputation: 8221

It makes sense to split the results in different requests in these cases, because you will render faster, since you do not preload all the results but only a part of them.

In your case, if the amount of data is not that much but you just want to handle they way you present them, you can split your results in blocks of a fixed number. You can add an extra block of results till they run out every time you scroll down.

Upvotes: 2

Related Questions