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. This includes Insert JavaScript, All-in-One, and All-in-One Lightbox actions.

The JavaScript editor in an action template as seen in an old version of the Monetate user interface

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 is possible to poll for the jQuery library so as not to attempt to run any code until it becomes available. This will be discussed in depth later in our Developer Training section.