ScriptLoader

ServiceNow's ScriptLoader.

Last modified 2025-06-20

Jace Benson

So if you want to reuse a script across many client scripts there's two ways I see it being able to be done easily. One, is to use a Script Include and a GlideAjax call to handle the logic server side. Two, is to create a UI Script and load it with ScriptLoader call described here or on the developer site.

Lets get to it. How to call this in a client script.

function onChange(control, oldValue, newValue, isLoading, isTemplate) { if (isLoading || newValue === '') { return; } ScriptLoader.getScripts('x_8821_catalog.awesome.jsdbx', function() { console.log('onchange'); console.log(x_8821_catalog.awesome); }); //Type appropriate comment here, and begin script below }