optimize JS scripts