Optimize code with require.js