I’m trying to add JavaScript to my mix project and the html.eex page is not reading it for some reason.
I have this at the end of my .eex file:
<script>
document.addEventListener("DOMContentLoaded", function () {
// Handler when the DOM is fully loaded
alert('test')
console.log('test')
});
</script>
OK. I tried it out the same script with the rumbl project from Chris’ Programming Phoenix book and it worked. It must be something specific to the repo I’m working with. Let me look into this more! Thank you @kokolegorille@LostKobrakai
Note that DOMContentLoaded will only fire if document.readyState is still in the loading state. By the time it is set to interactive (or later complete) the DOMContentLoaded event has already been fired.