javascript performance enhancement