protected void encodeSettingScripts(FacesContext context, PrimeRequestContext requestContext,
                                       PrimeConfiguration configuration, ResponseWriter writer) throws IOException {

        ProjectStage projectStage = context.getApplication().getProjectStage();
        ExternalContext externalContext = context.getExternalContext();

        writer.startElement("script", null);
        RendererUtils.encodeScriptTypeIfNecessary(context);
        writer.write("if(window.PrimeFaces){");

        writer.write("PrimeFaces.settings={");
        writer.write("locale:'" + LocaleUtils.getCurrentLocale(context) + "',");
        writer.write("viewId:'" + context.getViewRoot().getViewId() + "',");
        writer.write("contextPath:'" + externalContext.getRequestContextPath() + "',");
        writer.write("cookiesSecure:" + (requestContext.isSecure() && configuration.isCookiesSecure()));

        if (configuration.getCookiesSameSite() != null) {
            writer.write(",cookiesSameSite:'" + configuration.getCookiesSameSite() + "'");
        }

        writer.write(",validateEmptyFields:" + configuration.isValidateEmptyFields());
        writer.write(",considerEmptyStringNull:" + configuration.isInterpretEmptyStringAsNull());

        if (configuration.isEarlyPostParamEvaluation()) {
            writer.write(",earlyPostParamEvaluation:true");
        }

        if (configuration.isPartialSubmitEnabled()) {
            writer.write(",partialSubmit:true");
        }

        if (projectStage != ProjectStage.Production) {
            writer.write(",projectStage:'" + projectStage.toString() + "'");
        }

        Map<String, String> errorPages = PrimeApplicationContext.getCurrentInstance(context).getConfig().getErrorPages();
        if (!errorPages.isEmpty()) {
            int i = 0;
            writer.write(",errorPages:{");
            for (Map.Entry<String, String> entry : errorPages.entrySet()) {
                if (i > 0) {
                    writer.write(',');
                }

                String errorPageUrl = context.getExternalContext().getRequestContextPath() + entry.getValue();
                errorPageUrl = context.getApplication().evaluateExpressionGet(context, errorPageUrl, String.class);
                errorPageUrl = context.getExternalContext().encodeActionURL(errorPageUrl);

                writer.write("'" + (entry.getKey() == null ? "" : entry.getKey()) + "':'" + errorPageUrl + "'");

                i++;
            }
            writer.write("}");
        }

        writer.write("};");

        if (externalContext.getClientWindow() != null) {
            ClientWindow clientWindow = externalContext.getClientWindow();
            if (clientWindow instanceof PrimeClientWindow) {

                boolean initialRedirect = false;

                Object cookie = PrimeClientWindowUtils.getInitialRedirectCookie(context, clientWindow.getId());
                if (cookie instanceof Cookie) {
                    Cookie servletCookie = (Cookie) cookie;
                    initialRedirect = true;

                    // expire/remove cookie
                    servletCookie.setMaxAge(0);
                    ((HttpServletResponse) externalContext.getResponse()).addCookie(servletCookie);
                }
                writer.write(
                        String.format("PrimeFaces.clientwindow.init('%s', %s);",
                                PrimeClientWindowUtils.secureWindowId(clientWindow.getId()),
                                initialRedirect));
            }
        }

        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