DEV Community


Discussion on: Load specific JS files in Elixir and Phoenix

ricardoruwer profile image
Ricardo Ruwer Author

You will have an app.min.js file that was generated by Webpack and contains all your JS code.

But the idea of this guide is to have some kind of rule in our JS code that is similar to this:

if (myCurrentPage == "/contact") {
  // execute this piece code...

if (myCurrentPage == "/about-us") {
  // execute this other piece of code...

So we'll not execute code that is not necessary for some pages...

There's also a great library that I use sometimes and do almost the same thing:

popo63301 profile image
Sofiane Baddag

Oh okay ! I thought the idea was to create a JS file for each page. Makes sense now !

Thanks Ricardo !