Widgets are all the rage. LineBuzz is a widget and we like to think it rages too. We've built it to be very fast and very polite.
It's fast because we hook into the web page onload event and only do stuff that might be slow after your page has loaded and your users have something to read and look at.
Many widgets don't do that, and that's bad because if their servers go down or slow down then your page slows down too. Your page will stop loading at the point where you've inserted their Javascript and the browser will wait for their servers to respond. Your user waits about 3 seconds and then goes to someone else's blog.
LineBuzz is also very polite. We've written it to respect the needs of other widgets. We hook into the page onload event, but we make sure that anyone else who is using 'onload' will still run just fine. Here's the code we use - it's called a closure and is a well known javascript technique:
function LBSetup(){
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = LBOnLoad;
} else {
window.onload = function() {
oldonload();
LBOnLoad();
}
}
}
We even run everyone else's code before ours because we're super polite. :)
One of our users is using a widget from a company who shall remain nameless and they simply do this:
window.onload = myVeryRudeFunction;
Everything that uses onload on the page breaks. Very naughty. So I think our user is probably going to remove the other company's script because it may break more than just LineBuzz on the page.
So when you choose which widgets to run on your blog, make sure they're fast and polite.