Use External JavaScript files in your ServiceNow Instance
Navigate to System UI > UI Scripts. Click New. In script You can use global check box which indicates whether script loads on every page in the system ( Use caution when creating global UI scripts because they can impact performance ) You can also include this js file using script tag in your UI pages