Elm javascript file is not loading

I’m new to Phoenix and I’m starting a project that uses Elm running a small part of the page.

The problem I’m running into is that it seems the javascript is not loading or running in the browser.

I have manually placed the Elm JS file in priv/static/js as poller.js
I also manually updated the app.html.eex file to have a script tag to load this file in the head.

I tested that I can access the script file at http://localhost/js/poller.js, no problem file downloads.

But when I use a view template that includes inline JavaScript to bind the Elm application to the specific div element, the browser tells me that the Elm object is not there. If I look at the network traffic of the page in dev tools the page does not download the poller.js file.

I’m confused as to why the page is not downloading the javascript file. It seems to only download the OOTB app.js file.

Since you put it in priv/static/js as poller.js then you do have a script tag in your html to import that js file? Hard to say what the issue is otherwise since no code was shown. ^.^

Yes! Here is a snippet of HTML from the page.

<div class="row">
    <div id="poll" ></div>
<script scr="http://localhost/js/poller.js" ></script>
<script type="application/javascript">
  var node = document.getElementById('poll');

I did run this Elm application standalone, outside of phoenix, so I know it works fine. I ran it from an nginx server.

Ok…, I feel dumb. I just saw my error now, “scr” should be “src”, oh boy! I can’t tell you how long I stared at this.

1 Like

Needs to read src

Happens to us all! ^.^
And this is precisely why I like statically typed things. ^.^