You can update your digital workplace's jQuery library to transition custom HTML widgets and scripts to modern, secure jQuery libraries at your own pace. You can mitigate security vulnerabilities while ensuring your customizations remain functional by incrementally updating to new versions one at a time.
Sections in this article:
- Considerations
- Who can do this?
- Update a script to use a specific jQuery library variable
- Update the digital workplace's jQuery version
Considerations
- Required for testing: You must have a custom HTML Content widget using a jQuery script or a jQuery script located elsewhere in the digital workplace where you can test the new libraries.
Who can do this?
- Enterprise administrators
- Workplace administrators
Update the digital workplace's jQuery version
It is recommended that you incrementally update to newer versions of jQuery, and then check your scripts to ensure they are performing as expected. You can immediately revert to an older version to ensure scripts remain functional while you update them.
To update to a newer version of jQuery:
- On the Userbar, select
Control Panel and then Global Settings.
-
In jQuery Libraries, you can select from one of the following versions:
- v1.11.0 ($jq_legacy)
- v1.12.4 ($jq_1_12_4)
- v2.2.4 ($jq_2_2_4)
- v3.7.1 ($jq_3_7_1)
The newest selected version automatically becomes the global jQuery object (window.jQuery) for generic use. Each version automatically has an assigned variable that can be used to target a specific version in a script.
- At the bottom of the page, select Save.
Once you have updated the version, you should verify that your scripts are working as expected. If your scripts are performing well, repeat these steps until you have updated to the newest version.
Update a script to use a specific jQuery library variable
During your testing, you may discover a script that only works with a specific version of jQuery. You can update the script to use the customized variables for the new jQuery library from the Global Settings page. For example, you would replace $jq_legacy with $jq_1_12_4 on lines 12 and 13 in the following script:
<div>
<div id="cc">jquery <span class="dd">specific</span></div>
<script type="text/javascript">
(function($)
{
// Run when DOM is ready
$(function()
{
$('#cc').css('color', 'DarkCyan');
$('#cc .dd').css('color', 'purple');
});
})($jq_legacy);
console.log($jq_legacy.fn);
</script>
</div>The script would become:
<div>
<div id="cc">jquery <span class="dd">specific</span></div>
<script type="text/javascript">
(function($)
{
// Run when DOM is ready
$(function()
{
$('#cc').css('color', 'DarkCyan');
$('#cc .dd').css('color', 'purple');
});
})($jq_1_12_4);
console.log($jq_1_12_4.fn);
</script>
</div>