Converting Prototype’s Ajax.PeriodicalUpdater to jQuery
One of the things I missed when switching from Prototype to jQuery was the former’s Ajax.PeriodicalUpdater function. It is used to provide a ‘decay’ mechanism for ajax calls, making them less and less frequent if the retrieved content doesn’t change inbetween calls.
It can be a seriously useful piece of functionality. I took a chatroom that was polling every second and using an entire CPU core (50% usage!) and reduced it to 2-3% using this method. There were also errors retrieving content because sometimes the responses would take longer than a second to come back!
The problem is, there really isn’t a similar piece of functionality in jQuery.
So here it is! The script checks the returned data against previously received data, and increases the time between calls if it hasn’t changed.
I’d be interested in your comments. Would it be useful to turn this into a plugin?

This is awesome, I am going to use it!
Dude – write a plugin for this by the way… it would be very useful – and I would be happy to reblog it!
Great post… I guess it would be useful to turn into plug-ins…
That’s a great addition. I think it will make sense to provide this as a plug-in for jQuery. It only makes sense to throttle the number of requests being sent.
A very good explanation, helped much!
Thank you!
Very nice article!
It does work very well and of course that it will be usefull converting it to a plugin.
I´ll be thankfull!
Thanks for sharing this useful tip John!
great tutorial, it helped me a lot ! thanks