> only use it when necessary ie. when the user scrolls back to view old messages.

sorry, what I was wondering was how this can get accomplished without listening to the window scroll event