I am trying to include a new js file into my Statamic application. As per the Statamic documentation I changed the file AppServiceProvider.php
in the boot method I added
Statamic::script('App', 'newfile.js');
But it doesn't load the javascript file. Is there anything else I have to do to make the script working?
The
Statamic::scriptcode allows you to add JavaScript to Statamic's Control Panel, not onto your site, as explained in the Statamic documentation.To add a JavaScript file to the front-end of your site, you will want to find the layout file in
resources/views(possibly calledlayout.antlers.html).Then you will want to add the JS file inside the
<head>(or bottom of the<body>depending on what you need) of the layout, like so:Make sure you change
/js/new-file.jsto the path of your JS file.