add uglify to grunt task; refactor js code for better requirejs driven.