optimize source code for javascript