cdarsow
Tera Contributor

As a summerize for myself: a good starting point is to create UI scripts for shared client side JS Code.

 

The usage/including of those can then differ regarding where you want to use in the platform and for what purpose, eg. portal or non-portal usage.

 

For the usage inside catalog client scripts in portal-context, it seems a good way to provide those as theme JS includes. Even though than loaded on every single page of the portal, these should just be loaded once "really" and then be cached by the browser.

 

I keep the UI scripts in my application scope and additionally provide "module scope" inside my JS code to not clutter global scope, eg

 

window.MY_APP_SCOPE = window.MY_APP_SCOPE || {};
window.MY_APP_SCOPE.validation = (function () {
// some shared logic
})();