Answers.Body: <p><code>includeJsFile</code> links directly to the file. It doesn't try anything fancy, it just finds the file (exactly as you've referred to it) and creates a normal <code>&lt;script&gt;</code> tag for it.</p>
  
  <p><code>includeJsResource</code> looks for that file in a few different places. It could be a plugin resource, it could be a native Craft resource, etc.</p>
  
  <p>Whenever possible, stick to <code>includeJsFile</code>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-27T00:02:14.103Z
Answers.LastActivityDate: 2016-01-27T00:02:14.103Z
Answers.UserDisplayName: Lindsey D
Body: <p>As a solution to keep things segregated and clean in git, we started developing websites for craft with templates in the template folder, and js, css, etc in a plugin.  So each website had our base plugin (standard stuff like font-awesome, foundation, jquery, etc) and their website plugin (any additional libraries and their custom css/js).  As an added bonus, our clients could look at the plugin page in the admin panel and see "oh, cool... my website is built by [studio name]!"</p>
  
  <p>To load javascript and css, I used things like:</p>
  
  <pre><code>{% includeJsResource "pluginname/vendor/foundation/bower_components/modernizr/modernizr.js" first %}
  </code></pre>
  
  <p>We started to notice some significant speed issues.<br>
  So I switched to this:</p>
  
  <pre><code>{% includeJsFile "/assets/vendor/foundation/bower_components/modernizr/modernizr.js" first %}
  </code></pre>
  
  <p>the page loaded SIGNIFICANTLY faster.  Like, 3-7 seconds faster.  Which is a lifetime on the web.  The <a href="https://craftcms.com/classreference/services/TemplatesService" rel="nofollow">documentation</a> doesn't appear to make any mention of this.</p>
  
  <ul>
  <li><p>Why is includeJsFile so much faster?</p></li>
  <li><p>Is it possible to use includeJsFile AND keep my resources in the plugin directory?</p></li>
  </ul>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-27T01:18:35.770Z
Comments.Text: Wow. 3-7 seconds?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-27T08:50:24.577Z
Comments.Text: @carlcs That's what I thought as well. 3-7 seconds is _insane_; the performance hit shouldn't really be noticeable unless you're including a vast amount of files. Must be something else going on here.
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-27T16:14:23.330Z
Comments.Text: It was a website that was in progress, so it was including 10-20 js/css files per page on a crappy dev server that is essentially an overloaded shared host.  After minifying and combining all the files it would have sped up anyways but... yeah.  The performance difference surprised me.  Maybe PHP was getting a bigger hit than expected?  The key is probably the sheer number of files being included with includeJsResource.
Comments.UserDisplayName: Jonathan Walters
Tags: <plugin-development><plugins><craft-features><speed>
Title: includeJsFile vs includeJsResource
ThreadText: # includeJsFile vs includeJsResource
  
  (Asked by: username_0 on 2016-01-26)
  
  As a solution to keep things segregated and clean in git, we started developing websites for craft with templates in the template folder, and js, css, etc in a plugin. So each website had our base plugin (standard stuff like font-awesome, foundation, jquery, etc) and their website plugin (any additional libraries and their custom css/js). As an added bonus, our clients could look at the plugin page in the admin panel and see "oh, cool... my website is built by [studio name]!"
  
  To load javascript and css, I used things like:
  
  ```
  {% includeJsResource "pluginname/vendor/foundation/bower_components/modernizr/modernizr.js" first %}
  
  ```
  
  We started to notice some significant speed issues.  
  So I switched to this:
  
  ```
  {% includeJsFile "/assets/vendor/foundation/bower_components/modernizr/modernizr.js" first %}
  
  ```
  
  the page loaded SIGNIFICANTLY faster. Like, 3-7 seconds faster. Which is a lifetime on the web. The [documentation](https://craftcms.com/classreference/services/TemplatesService) doesn't appear to make any mention of this.
  
  * Why is includeJsFile so much faster?
  * Is it possible to use includeJsFile AND keep my resources in the plugin directory?
  
  **Tags:** plugin-development, plugins, craft-features, speed
  
  > **Comments:**
  > **username_1**: Wow. 3-7 seconds?  
  > **username_2**: @username_1 That's what I thought as well. 3-7 seconds is _insane_; the performance hit shouldn't really be noticeable unless you're including a vast amount of files. Must be something else going on here.  
  > **username_0**: It was a website that was in progress, so it was including 10-20 js/css files per page on a crappy dev server that is essentially an overloaded shared host.  After minifying and combining all the files it would have sped up anyways but... yeah.  The performance difference surprised me.  Maybe PHP was getting a bigger hit than expected?  The key is probably the sheer number of files being included with includeJsResource.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2016-01-27. Score: 2
  
  `includeJsFile` links directly to the file. It doesn't try anything fancy, it just finds the file (exactly as you've referred to it) and creates a normal `<script>` tag for it.
  
  `includeJsResource` looks for that file in a few different places. It could be a plugin resource, it could be a native Craft resource, etc.
  
  Whenever possible, stick to `includeJsFile`.
  
  
  ---
  
  