Show spinner while javascript code is loading

If it's a loading spinner for the whole page you could use a preloader:

If it's for a section of the page, you can add the spinner and set
dmx-show="serverconnnectname.state.executing"