Answers.Body: <p>Use the <code>rev</code> function provided by the plugin to get the path to your JS file (relative to the asset base path) and register it with the <code>{% js %}</code> tag:</p>
  <pre class="lang-twig prettyprint-override"><code>{% js rev('js/foobar.js') at head with { defer: true } %}
  </code></pre>
  <p>Another option that I like to use is to declare a block in the base template and then extend it the page specific template:</p>
  <pre class="lang-twig prettyprint-override"><code>{# templates/_private/layout/index.html #}
  {% block assets %}
      &lt;link rel=&quot;stylesheet&quot; href=&quot;{{ rev('main.css') }}&quot;&gt;
  {% endblock %}
  </code></pre>
  <pre class="lang-twig prettyprint-override"><code>{# templates/_private/your-page.html #}
  {% extends '_private/layout/index.html' %}
  
  {% block assets %}
      {{ parent() }}
      &lt;script src=&quot;{{ rev('js/foobar.js') }}&quot; defer&gt;
  {% endblock %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-02T12:22:38.337Z
Answers.LastActivityDate: 2022-06-02T12:22:38.337Z
Answers.UserDisplayName: MoritzLost
Body: <p>I'm practicing with <a href="https://github.com/craftcms/starter-blog" rel="nofollow noreferrer">starter-blog template</a>.</p>
  <p>How do I include a page specific javascript using the asset rev plugin?</p>
  <p>Thanks.</p>
  
Tags: <javascript>
Title: How to use page specific javascript using the starter-blog template using asset rev plugin?
ThreadText: # How to use page specific javascript using the starter-blog template using asset rev plugin?
  
  (Asked by: username_0 on 2022-06-02)
  
  I'm practicing with [starter-blog template](https://github.com/craftcms/starter-blog).
  
  How do I include a page specific javascript using the asset rev plugin?
  
  Thanks.
  
  **Tags:** javascript
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-06-02. Score: 2 | Accepted answer
  
  Use the `rev` function provided by the plugin to get the path to your JS file (relative to the asset base path) and register it with the `{% js %}` tag:
  
  ```twig
  {% js rev('js/foobar.js') at head with { defer: true } %}
  
  ```
  
  Another option that I like to use is to declare a block in the base template and then extend it the page specific template:
  
  ```twig
  {# templates/_private/layout/index.html #}
  {% block assets %}
      <link rel="stylesheet" href="{{ rev('main.css') }}">
  {% endblock %}
  
  ```
  
  ```twig
  {# templates/_private/your-page.html #}
  {% extends '_private/layout/index.html' %}
  
  {% block assets %}
      {{ parent() }}
      <script src="{{ rev('js/foobar.js') }}" defer>
  {% endblock %}
  
  ```
  
  
  ---
  
  