These docs are for v1.0. Click to read the latest docs for v2.0.

All Cratejoy themes may use JavaScript to customize the layout and functionality of the site inside your customer's browser.

Old themes (v1.0) do not have components and cannot use the component.js file like newer themes (v2.0) can. To add custom JavaScript tags to your page use the page_javascript Jinja block in your templates:

{% block page_javascript %}
<script type="text/javascript">
	$("body").css("background-color", "red");
</script>
{% endblock %}

This code will automatically added to the end of your page to ensure your pages load quickly. All plugins defined in your base.html will be included before this tag, so feel free to use jQuery and Bootstrap plugins here.

Some things to note:

  • Each page can only have one {% block page_javascript %} tag. If you need multiple script tags, include them all in a single block.
  • If you remove the {% block page_javascript %} tag from your base.html this feature will no longer work.

🚧

Any customizations done with JavaScript are not supported by Cratejoy's customer support. If you are not familiar with JavaScript and need to use it, we recommend working on a copy of your theme and working with a more advanced web developer.