Introduction to jQuery

jQuery is one of the most popular JavaScript libraries in the world. It offers a lightweight set of tools that make it easier to use JavaScript on your website.

The jQuery logo

jQuery simplifies many of the complex features of "vanilla" JavaScript. It makes it easy for webpage developers to do common tasks like manipulating the webpage, responding to user events, getting data from their servers, building effects and animations, and much more. jQuery wraps common tasks that require many lines of JavaScript code into simple methods that you can call with a single line of code.

Because it is one of the most widespread libraries in use, jQuery also boasts a broad range of plugins.

The jQuery library contains the following features:

  • HTML/DOM manipulation
  • CSS manipulation
  • HTML event methods
  • Effects and animations
  • AJAX
  • Utilities

Using jQuery in Monetate Actions

You can use jQuery in numerous Monetate actions—anywhere you can insert JavaScript.

The JavaScript editor in an action template, with jQuery code input into the editor

The only potential limitation to using jQuery over traditional plain JavaScript in an action is timing. Because jQuery is a library, you cannot use the library until it has loaded on the user's end. Typically, because jQuery is so widespread and popular and because it is often loaded in the <head> section of a webpage, this is not a major issue since the library is either cached locally for many users or its load time is minimal because it is called early during the page load.

Example script declaring the jQuery library

<script src=""></script>

If you have concerns about timing for whatever reason, it's possible to poll for the jQuery library so as not to attempt to run any code until it becomes available.