<p>One way to include JS (or CSS) files, is to use the <a href="http://buildwithcraft.com/docs/templating/includejsfile" rel="nofollow">includeJsFile</a> tag.
This tag will queue your file and append to the end of the <code>&lt;body&gt;</code>.
If, for some reason, you don't want this (say you want to include JQuery in the <code>&lt;head&gt;</code>), I would just use <code>&lt;script src=""&gt;</code> etc.</p>

<p>This might also solve your second problem.</p>

CC BY-SA 3.0
2014-10-08T07:29:19.760Z
Hmm, that didn't work either. I don't know what is going on, but it might be a bug of sorts. It just fails to load the script if it has .min.js as the extension, and modernizr.js
Ryan
CC BY-SA 3.0
2014-10-08T07:46:34.723Z
Something to do with twig or craft checking the js file... !
Ryan
CC BY-SA 3.0
2014-10-08T07:48:24.863Z
Have you tried loading it directly with a <script> tag? Twig does nothing with script tags, so if that doesn't work, you can rule out a template problem.
Paul
CC BY-SA 3.0
2014-10-08T07:50:06.593Z
Did you put your JS and CSS files in the templates folder? Then don't. If they're in your public folder, Twig or Craft has nothing to do with 'em.
Paul
CC BY-SA 3.0
2014-10-08T08:09:23.710Z
Ahhh ok, I'll move them there. So it's all css images, js files, vendor stuff. CSS as well?
Ryan
CC BY-SA 3.0
2014-10-08T16:31:57.213Z
I keep everything in public, so Twig or Craft have nothing to do with it.
Paul
CC BY-SA 3.0
2014-10-08T07:15:50.863Z
2014-10-08T07:15:50.863Z
Paul
<p>I am including head.html and scripts.html in my template. Most of the scripts load except for 2 yet the path is the same for all of them. I {% include %} them.</p>





<p>If I change foundation.min.js to foundation.js it works. The min file exists. </p>

<p><strong>Update:</strong>
This is because JS files are checked for errors before being loaded. For example, if I visit those URL's directly it will show me an error. Any way to stop that?</p>

<p><a href="http://craft.dev/bower_components/foundation/js/foundation.min.js" rel="nofollow noreferrer">http://craft.dev/bower_components/foundation/js/foundation.min.js</a></p>

<p><img src="https://i.sstatic.net/F5w8O.png" alt="JS Error"></p>

<p>Update:</p>

<pre><code>&lt;script src="/bower_components/jquery/dist/jquery.min.js"&gt;&lt;/script&gt;
&lt;script src="/bower_components/foundation/js/foundation.min.js"&gt;&lt;/script&gt;
&lt;script src="/bower_components/imagesloaded/imagesloaded.pkgd.min.js"&gt;&lt;/script&gt;
&lt;script src="/bower_components/velocity/velocity.min.js"&gt;&lt;/script&gt;
&lt;script src="/bower_components/velocity/velocity.ui.min.js"&gt;&lt;/script&gt;
&lt;script src="/bower_components/wookmark-jquery/jquery.wookmark.min.js"&gt;&lt;/script&gt;
&lt;script src="/js/app.js"&gt;&lt;/script&gt;
</code></pre>

CC BY-SA 3.0
2014-10-08T07:51:48.617Z
Can you show me the part of your script.html file where you call the JS files?
Paul
CC BY-SA 3.0
2014-10-10T02:22:55.520Z
Sure, updated it. It wasn't the HTML though, something parses those scripts and checks them.
Ryan
<url><include>
Correct way to include include scripts
# Correct way to include include scripts

(Asked by: username_0 on 2014-10-08)

I am including head.html and scripts.html in my template. Most of the scripts load except for 2 yet the path is the same for all of them. I {% include %} them.
If I change foundation.min.js to foundation.js it works. The min file exists. 
Update:
This is because JS files are checked for errors before being loaded. For example, if I visit those URL's directly it will show me an error. Any way to stop that?
http://craft.dev/bower_components/foundation/js/foundation.min.js

Update:

**Tags:** url, include

> **Comments:**
> **username_1**: Can you show me the part of your script.html file where you call the JS files?  
> **username_0**: Sure, updated it. It wasn't the HTML though, something parses those scripts and checks them.  

---

## 1 answers

### Answer by username_1 on 2014-10-08. Score: 1 | Accepted answer

One way to include JS (or CSS) files, is to use the [includeJsFile](http://buildwithcraft.com/docs/templating/includejsfile) tag.
This tag will queue your file and append to the end of the .
If, for some reason, you don't want this (say you want to include JQuery in the ), I would just use

> **Comments:**
> **username_0**: Hmm, that didn't work either. I don't know what is going on, but it might be a bug of sorts. It just fails to load the script if it has .min.js as the extension, and modernizr.js  
> **username_0**: Something to do with twig or craft checking the js file... !  
> **username_1**: Have you tried loading it directly with a <script> tag? Twig does nothing with script tags, so if that doesn't work, you can rule out a template problem.  
> **username_1**: Did you put your JS and CSS files in the templates folder? Then don't. If they're in your public folder, Twig or Craft has nothing to do with 'em.  
> **username_0**: Ahhh ok, I'll move them there. So it's all css images, js files, vendor stuff. CSS as well?  
> **username_1**: I keep everything in public, so Twig or Craft have nothing to do with it.  

---

