fixed #2452:optimize javascript code