1

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

JS Error

Update:

<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<script src="/bower_components/foundation/js/foundation.min.js"></script>
<script src="/bower_components/imagesloaded/imagesloaded.pkgd.min.js"></script>
<script src="/bower_components/velocity/velocity.min.js"></script>
<script src="/bower_components/velocity/velocity.ui.min.js"></script>
<script src="/bower_components/wookmark-jquery/jquery.wookmark.min.js"></script>
<script src="/js/app.js"></script>
  • Can you show me the part of your script.html file where you call the JS files? – Paul Oct 8 '14 at 7:51
  • Sure, updated it. It wasn't the HTML though, something parses those scripts and checks them. – Ryan Oct 10 '14 at 2:22
1

One way to include JS (or CSS) files, is to use the includeJsFile tag. This tag will queue your file and append to the end of the <body>. If, for some reason, you don't want this (say you want to include JQuery in the <head>), I would just use <script src=""> etc.

This might also solve your second problem.

| improve this answer | |
  • 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 Oct 8 '14 at 7:29
  • Something to do with twig or craft checking the js file... ! – Ryan Oct 8 '14 at 7:46
  • 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 Oct 8 '14 at 7:48
  • 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 Oct 8 '14 at 7:50
  • Ahhh ok, I'll move them there. So it's all css images, js files, vendor stuff. CSS as well? – Ryan Oct 8 '14 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.