js code reorg