I just reread that and noticed you mentioned you’re including a header, body etc in the html. I recommend checking the widget guide in the Duda developer documentation thoroughly.
The widget should not be using those elements. An example of a widget would be adding something like adding a list of items to render on the page. There are examples in the documentation. I use event listeners in most of my widgets so they will 100% work but you’ll need to put all of your scripts into the JS page and your html document should only be the content you’re rendering and if an html document to add to an existing html document.