How to install a third-party script on a template?

Can you give an example of how to add a javascript library to a site?

1 replies

Let's say you want to install the library instant.page on your website. Their documentation tells us we need to add the following just before our site's </body> tag:

<script src="//instant.page/5.1.1" type="module" integrity="sha384-MWfCL6g1OTGsbSwfuMHc8+8J2u71/LA8dzlIN3ycajckxuZZmF+DNjdm7O6H3PSq"></script>

Let's assume you're using the Blog template. You'll first need to 'Fork' an editable copy of the template on your Template settings page.

Open up the template editor and navigate to the 'Source code' tab in the sidebar. Then find the template file footer.html, which contains the code used to render the bottom of your blog's layout (i.e. the footer, as opposed to the header).

You will want to insert the HTML required by instant.page into this file, which will be included in every page rendered on your site. In the case of the Blog template, the resulting footer.html file should look like this once you're done:

<script src="{{{scriptURL}}}" type="text/javascript"></script>
<script src="//instant.page/5.1.1" type="module" integrity="sha384-MWfCL6g1OTGsbSwfuMHc8+8J2u71/LA8dzlIN3ycajckxuZZmF+DNjdm7O6H3PSq"></script>

Does that help? Please let me know if you have any questions about this or anything else

Answered 6 months ago · Improve this answer

Markdown allowed
Question or feedback?
Contact us

Tags

developers 28 questions bug 14 questions posts 9 questions resolved 7 questions request 6 questions google-drive 5 questions configure 4 questions pages 3 questions added 3 questions meta 3 questions More tags →
Subscribe for changes
RSS Feed of latest questions