front-end js rewrite