The addition of the event listener before page load causes the resizeListener to fire which results in a user experience of the init and prompt commands re-running (see picture). Running on Chrome.

Simplest, if slightly inelegant solution is to simply wrap it and wait for the page load.
window.on('load', () => {
window.addEventListener("resize", term.resizeListener);
});