Setup

Adding HeadJS to your site

The most common way to include HeadJS on your site will be to include it in the <head>

{% highlight html %} {% endhighlight %}

But sometimes you might want it to load up a bunch of code right away, without having to declare that code in a new <script> tag. This can be very useful when using code-generation, or even if you just want to stick all your code in a centralized place.

{% highlight html %} {% endhighlight %}

In the above example you would put your code in init.js, which would be called automagically

{% highlight js %} // init.js head.load("file1.js", "file2.js"); {% endhighlight %}

Note: Only the first detected instance of data-headjs-load will be used, so make sure there is only one on the page.

Show Comments