Exposing version of jQuery globally

The built-in jQuery is currently declared as an AMD module. By default, jQuery will not be available in the window object of the browser. This section shows how to make jQuery available so you can write a code like in a plain script.

The following script will make jQuery available by mounting the jQuery object in the window object:

require( ["SHARED/jquery"], function($) {
  // the '$' in window.$ is alias, you can make the other for yourself.
  window.$ = $;

This script must be integrated as a shared script:


A portlet can then provide its own script on which it depends:


With the following JavaScript:

$("#foo").html("<h1>hello global jQuery</h1>");
Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus