I have this huge Javascript GUI that takes like 10 seconds to boot up. I would like to not let the user see the DOM getting hacked to pieces as it’s loading. So I was wondering how to do an “onBeforeLoad” event like Gmail:

Basically, I’d want a Preloader object to be run right off the bat and I’ll have all my large JS files ping it at different points of the initialization:
// move loading bar up 10%
MYAPP.preloader.increase(.10);
So how do I instantiate my Preloader object before the body loads?