Using an Underscore CDN Combination

underscore cdn

What is Underscore.js?

Underscore.js is a library of JavaScript functions useful for common programming tasks. It takes advantage of functional programming design therefore there is no need to extend any built-in objects. It provides over 100 functions that support both common functional helpers and more specialized tasks. The functions fall under four main categories which include:

  • Array manipulation
  • Object manipulating
  • Array and object manipulation (category name is “Collections”)
  • Other function manipulation

The Underscore.js file can be downloaded and hosted on your origin server, however for faster delivery, it can also be referenced using an Underscore CDN combination.

How to Use an Underscore CDN Combination

There are a couple of options available when wanting to accelerate Underscore.js through using a CDN. One option is to accelerate the file with your existing CDN account (if you have one) and the other option is to use a third party CDN service to reference the file from. Both options are discussed in the following section.

Option 1 – Using Your Own CDN Account

If you already have an existing CDN account, you can simply accelerate your Underscore.js file using said CDN. In the case of KeyCDN, this can be done either by using a Pull Zone or Push Zone depending on your integration requirements. If using a pull zone, upon following an integration guide that corresponds to your CMS or framework, the static Underscore.js file will be automatically pulled from your origin server and delivered from the CDN edge servers once it is cached.

Alternatively, if using a push zone, you can simply upload the latest version of Underscore.js and reference it in your project using the zone URL (e.g. lorem-1c6b.kxcdn.com/js/underscore.min.js) or Zonealias (e.g. https://cdn.example.com/js/underscore.min.js).

Option 2 – Using an Open Source CDN

Another option for using an Underscore JS CDN combination, if you do not have a CDN account, is to reference the file using a service such as jsdeliver.com. This open source CDN allows you to search for JS libraries, CSS frameworks, etc. The JSdeliver Underscore.js file can be referenced using the following snippet (ensure that you first check for the latest version x.y.z).

<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/x.y.z/underscore-min.js"></script>

Benefits of an Underscore CDN Combination

Now that you are delivering the Underscore.js file via a CDN, your website will receive a boost in performance and a reduction in latency. Using a CDN for JS libraries, CSS frameworks, Jquery plugins, etc. not only increases their delivery speed but also helps improve redundancy and increase security. Read our 7 reasons you should use a CDN article to learn more. Additionally, there exists many other benefits to users who accelerate their Underscore.js file and other static content with KeyCDN: