Edit in JSFiddle

/*** Function Credit: Jim Marion
* Resource: http://jjmpsj.blogspot.com/2015/02/using-requirejs-to-manage-dependencies.html
* Build a URL based on the current component's URL
* @param {type} scriptId* @returns {String} derived URL for JavaScript
*/
var getScriptUrl = function (scriptId) {	
	var mainUrl = window.location.href;	
	var parts = mainUrl.match(/ps[pc]\/(.+?)(?:_\d)*?\/(.+?)\/(.+?)\/[chs]\//);	
	return window.location.origin + "/psc/" + parts[1] + "/" + parts[2] + "/" + parts[3] + "/s/WEBLIB_PTBR.ISCRIPT1.FieldFormula.IScript_GET_JS?ID=" + scriptId;
};

/*** Improvised from delivered JavaScript: PT_CHART_LOAD - loadScript Function
* Load JavaScript to Document* @param {type} sURL
* @param {type} sId
* @param {type} callback
*/
var cskLoadJS = function(sURL, sId, callback) {	

	var oElement= document.getElementsByTagName('head')[0];	
	var oScript= document.createElement('script');	
	oScript.type= 'text/javascript';	
	oScript.language='JavaScript';	

	//% console.log('cskLoadJS: ' + sId); 	
	
	if(oScript.readyState)	{		
		oScript.onreadystatechange=function()  //for IE		
		{			
			if(oScript.readyState=="loaded"||oScript.readyState=="complete")			
			{				
				oScript.onreadystatechange=null;
			}	    
		}	
	}	else	{   
		oScript.onload=function()		
		{
			  //% console.log('	' + sId + 'onload callback: ' + callback); 
		    if (typeof(callback) === 'function')
		    {
	    	    callback(callback);
	    	}			
			
		};	
	}	
	
	oScript.src= sURL;	
	oScript.id= sId;    
	oElement.appendChild(oScript);    
};

/* Inject custom javascripts */
var cskInjectJS = function(){

	/*     
	* Inject custom JS using getScriptUrl and cskLoadJS functions	
	* cskLoadJS(getScriptUrl('CSK_FL_TEST_JS'), 'CSK_FL_TEST_JS', callbackFunction);     
	* cskLoadJS(getScriptUrl('CSK_FL_TEST_JS'), 'CSK_FL_TEST_JS', 'sCntr');     
	*/    

	//% console.log('cskInjectJS'); 
	cskLoadJS(getScriptUrl('CSK_FL_DBNAME_JS'), 'CSK_FL_DBNAME_JS', 'sCntr');	
    				
};

/* Main Function that gets invoked immediately */
(function () {	    

	/* Load requireJS from Oracle JET directory */	
	var wsPath = '/cs/' + getSiteName();        
	//% console.log('CSK_FL_BOOTSTRAP_JS: ' + wsPath);  	

  /* Load require.js */
	cskLoadJS(wsPath + '/oraclejet/js/libs/require/require.js', 'CSK_REQUIRE_JS', 'sCntr');      

  /* 
	* Load custom require.js configuration and pass cskInjectJS as the callback function.
	* This will ensure that cskInjectJS will only get invoked after CSK_REQUIRE_CFG_JS is loaded.
	*/
    cskLoadJS(getScriptUrl('CSK_REQUIRE_CFG_JS'), 'CSK_REQUIRE_CFG_JS', cskInjectJS);     		
	
}());