Only attach events after window load

Prevent a bug whereby the JavaScript was loaded before the body tag (ie: in the head)