protected void encodeInitScripts(FacesContext context, PrimeRequestContext requestContext, PrimeConfiguration configuration,
                                    ResponseWriter writer) throws IOException {
        List<String> scripts = requestContext.getInitScriptsToExecute();

        if (scripts.isEmpty()) {
            return;
        }

        writer.startElement("script", null);
        RendererUtils.encodeScriptTypeIfNecessary(context);

        boolean moveScriptsToBottom = configuration.isMoveScriptsToBottom();

        if (!moveScriptsToBottom) {
            writer.write("(function(){const pfInit=()=>{");
            writer.write(String.join(";", scripts));
            writer.write("};if(window.$)$(pfInit);");
            writer.write("else if(document.readyState==='complete')pfInit();");
            writer.write("else document.addEventListener('DOMContentLoaded',pfInit)})();");
        }
        else {
            writer.write(String.join(";", scripts));
            writer.write(';');
        }

        writer.endElement("script");
    }
Renders head content based on the following order
- First Facet
- Theme CSS
- PrimeIcons CSS
- Middle Facet
- Registered Resources
- Client Validation Scripts
- Locales
- PF Client Side Settings
- PF Initialization Scripts
- Head Content
- Last Facet
primefaces/src/main/java/org/primefaces/renderkit/HeadRenderer.java