Rewrite dependencies.js

Less code + greater performance = WIN!
About 0.5ms performance gain on my machine, primarly by touching the DOM just once.