I am using JSF 2.2.4 with the following in head tag:
<h:outputScript library="javax.faces" name="jsf.js" />
Later I found following post and removed the above code as it will be included automatically: renaming jsf.js.jsf to jsf.js.xhtml
When I checked found that it is included automatically as said but we are getting error with a script that is put in the head of common template. The error is the script is getting the object jsf as undefined. The purpose of this script is to show a common loader for all JSF AJAX calls. The script is given below:
//To display loading indicator for all JSF f:ajax calls.
jsf.ajax.addOnEvent(function(data) {
  var ajaxstatus = data.status; // Can be "begin", "complete" and "success"
  switch (ajaxstatus) {
    case "begin": // This is called right before ajax request is been sent.
      wizShowAjaxLoader();
      break;
    case "complete": // This is called right after ajax response is received.
      wizHideAjaxLoader();
      break;
    case "success": // This is called when ajax response is successfully processed.
      // NOOP.
      break;
  }
});
I wonder why it is working when I explicitly include jsf.js. When I remove this, script is showing jsf object as undefined.
 
     
    