Cleaning up JS and adding a root path depth to the body element