In my project using JSF 2.2.4, I initially included the following code in the head tag:
<h:outputScript library="javax.faces" name="jsf.js" />
However, after stumbling upon a helpful post about renaming jsf.js to jsf.js.xhtml, I decided to remove the above code as it was supposed to be automatically included: renaming jsf.js.jsf to jsf.js.xhtml
Although the inclusion of jsf.js was happening automatically as expected, we encountered an error related to a script placed in the common template's head section. The error indicated that the object jsf was being recognized as undefined. This particular script was created to display a loader for all JSF AJAX calls and is shown 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;
}
});
The issue arises when I exclude the explicit inclusion of jsf.js. Without it, the script encounters difficulties and reports the jsf object as undefined.