Testing and optimizing js