decouple js code