Let's add some javascript to our cims code for Jay Query will use A C D n select the many find version
and copy the script tag.
We'll paste it in the footer include just before the closing body tag.
Let's also add a file where we can put our own javascript code.
It's common practice to put javascript files in a J s folder.
And in here let's create a new file called script.
J s.
We'll display a message from here.
Just so that we can check it's working.
Let's add a reference to this file in the footer after the J query one.
If we go to our site in a browser.
We see the message on the home page and if we view an individual article we see it also.
So we know the script file is being loaded on all pages because it's in the footer.
If I go to the admin index However we don't see the message.
When I added the reference to the script file in the footer I started with the name of the folder then
the file name.
You are Ell's like this are relative to the current page.
So in scripts in the root.
This works as the JS folder is also in the root.
However for pages in a subdirectory for example the admin index as we just saw the browser tries to
load the script from a J s folder inside the admin folder which it doesn't find and therefore the page
isn't loaded.
To fix this we simply need to start the eurail with a slash.
This means that the file will always be loaded relative to the root of the site.
Now if we go to the admin index we see the message and also if we view an individual article in the
admin section.
So now we're loading our custom javascript file correctly on every page.
We can remove this message.