Reorganize js scripts