Wait for document to load before init

Needed for dev enviroment