<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>

CC BY-SA 4.0
2022-06-02T12:22:38.337Z
2022-06-02T12:22:38.337Z
MoritzLost
<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>

<javascript>
How to use page specific javascript using the starter-blog template using asset rev plugin?
# 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:
{% 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:
{# templates/_private/layout/index.html #}
{% block assets %}
    
{% endblock %}

{# templates/_private/your-page.html #}
{% extends '_private/layout/index.html' %}

{% block assets %}
    {{ parent() }}


---

