Custom JavaScript

Each Squarespace site comes with YUI3 built in and a script loader that minifies and combines your custom scripts.

Using the Script Loader

Squarespace's script loader minifies your code and allows you to combine all of your JavaScript files into one, cutting down on HTTP requests.

Loading JavaScript in Squarespace is very similar to the standard script tag syntax in HTML. The syntax is outlined in the code sample below.

Squarespace Script Loader

<squarespace:script src="plugin.js" combo="true" />
<squarespace:script src="site.js" combo="true" />

Libraries

Each site comes with YUI3 built in. All Squarespace engineers use the library. Although not as popular as JQuery, YUI3 is a modern, fully-featured library. If you're a JQuery developer who'd like to get started coding in YUI3, check out the JQuery - YUI3 Rosetta Stone.

Using JQuery

You can use JQuery, or any other library, on your Squarespace site. We recommend using the Google CDN hosted version of JQuery with a local fallback file. This method has been adopted by HTML5 boilerplate.

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="scripts/jquery-2.0.0.min.js"><\/script>')</script>