Rework the js handler
Add the register hook for listeners