Use same pattern for lines 96 and 97 as you use for mqtt: pack them in the connected event for wifi... you may need to keep track of the things that have successfully initialized / connected and need not to be initialized / connected again.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Use same pattern for lines 96 and 97 as you use for mqtt: pack them in the connected event for wifi... you may need to keep track of the things that have successfully initialized / connected and need not to be initialized / connected again.