ServiceNow uses JavaScript and makes use of both client-side and server-side programming. Although there are tasks both types can do, there are some tasks that can only be done client-side and other tasks that can only be done server-side.
Client-side programming is often preferred by users, due to the immediate interactivity of the scripts. Server-side programming is often preferred by developers due to eased complexity and better performance.
Let's look into what both types are and their advantages and disadvantages.
Client-side Programming
ServiceNow Client scripts are Javascript that runs on the client-side (the user's web browser) and instead of the server (on the server). Often it is used for immediate form changes, form validation, or user input, and when limited database lookups are needed. The ServiceNow Service Catalog often uses client side, "Catalog Client Scripts".
Types of client scripts
onLoad(): Runs when a form is loaded.
onChange(): Runs when a particular widget changes value.
onSubmit(): Runs when a form is submitted.
onCellEdit(): Runs when a cell on a list changes value.
A full list of all the places ServiceNow uses Client scripting can be found on the ServiceNow Client Scripting Wiki
Advantages
Can run immediately on field change or form load
Can provide interactive windows with AJAX
Disadvantages
No sequencing for client scripts running on same table
Can affect performance
Can be more difficult to write than server-side programming such as business rules
Limited GlideRecord queries (Should use GlideAjax instead)
No access to certain ServiceNow libraries such as GlideSystem
Can be affected by the type of browser used
Limited database calls should be utilized due to performance
Client Script Wiki Articles
Server-Side Programming
ServiceNow Server-side programming like business rules, is JavaScript configured to run when a record is displayed, inserted, updated, deleted, or when a table is queried.
ServiceNow uses server-side scripting in areas such as:
Business Rules
Script Includes
Script Actions
Reference Qualifiers
Transform Map Scripts
Workflow Scripting
A full list of all the places ServiceNow uses Server scripting can be found on the ServiceNow Server Scripting Wiki
Advantages
Performance. When running code on the server, it often has a faster load time and processing time than a client script
Not affected by type of browser
Can perform complex database lookups
Can dot-walk many levels, however three levels is often a recommend maximum
Disadvantages
Not as interactive as client scripts, needs an event like save, delete, or display to run
Server-side Script Wiki Articles