Update dom.js

1. Factored out a few redundancies in the AMD wrapper and improved it as a whole.
2. Decided to keep the "global" variable intact, as other libraries may follow the convention of defining it and thus can benefit from using it.