Refactor frontend scripts #3165