CS: improve JavaScript code

* remove unnecessary variables
* remove unused methods
* use more efficient jQuery selectors
* consistent return types in functions
* don't wait for unused dependencies to be loaded
* remove unused method parameters