Factoring js file