Javascript Loader with collision detection inspired by head.js