I think you could avoid the setTimeout by moving this to the load event instead of DOMContentLoaded (at least for Firefox). I haven't verified this though. I guess whether that's a good idea depends on how much you dislike the setTimeout and how long it takes before the load event fires.