Adding jQuery to a theme | HCL Digital Experience
The jQuery library is a JavaScript library. HCL Digital Experience includes a jQuery module for the jQuery core so you can use jQuery in a theme.
About this task
This jQuery module is not turned on by default. jQuery is an open framework and is not supported by HCL. The module makes it quick and easy to use jQuery and any of its plug-ins in a theme.
Procedure
- To turn on jQuery, copy the jquery1.10.2.json module definition file into your theme's contributions folder in WebDAV fs-type1. This jquery1.10.2.json file can be found at PortalServer\theme\wp.theme.jquery\installedApps\wp.theme.jquery.ear\wp.theme.jquery.war\v1.10.2.
- Optional: To enable plug-ins with the jQuery
core, download the jQuery plug-in from the jQuery website For more
information, see jQuery plug-in download in the related
links. In this example, use the PowerTip plug-in. The jquery.powertip-1.2.0.zip file.
To download the plug-in, see jQuery PowerTip plug-in download in
the related links.
- Add the module
jquery
to the module listings in one of your theme's profiles. Rather than modify one of the existing profile files, it is best to copy one of them and modify the copy. Copy the base profile file that you want to be similar to, such as profile_deferred.json, rename it to something such as profile_jquery_deferred.json and add the modulejquery
. When you create a profile file, adjust the titles and descriptions so that your profile has a unique and recognizable title and description.For example, change the titles and descriptions to"titles": [ { "value": "jQuery Deferred", "lang": "en" } ], "descriptions": [ { "value": "This profile has jQuery plus the full set of modules for the theme, but defers loading most of these modules unless actually needed. This profile balances function and performance.", "lang": "en" } ]
- Optional: Add the plug-in modules to the module
listings in your profile, such as add the module
jquery_powertip
in this example. - Invalidate the cache so that your profile and module changes are picked up by the Portal server. Click the Administration menu icon. Then, click . Then, click . Auto invalidation recognizes your changes automatically for WebDAV based themes. No further action is required. For more information, see Utilities.
- Apply your profile to a page. In
jQuery Deferred
. , select your Profile: - To verify that jQuery is loaded on a page and what version
it is, you can run
$().jquery
in the console of your browser's developer tools.It echoes the jQuery version number.