fix: JavaScript code improvement according to optimization guides