Have you worked with ClientGlobalContext yet?
Often times while writing your JS you need to reference the environment. Here’s where ClientGlobalContext.js.aspx comes into play. Reference it from your script using:
assuming you are using folders to differentiate your resources
This gives you access to several functions and global variables. The most notable are:
Functions: getOrgUniqueName, getQueryStringParameters, getUserId and getUserRoles
Global Variables: ORG_UNIQUE_NAME, AUTHENTICATION_TYPE, IS_ONLINE
There’s a few others, but I find that these are the ones I use the most.