@Test
    void includeScripts() throws IOException {
        writer.startElement("body", null);
        verify(wrappedWriter).startElement("body", null);

        writer.startElement("script", null);
        writer.writeAttribute("src", "url1", null);
        writer.endElement("script");

        writer.startElement("script", null);
        writer.writeAttribute("src", "url2", null);
        writer.endElement("script");

        writer.startElement("script", null);
        writer.writeAttribute("src", "url2", null);
        writer.endElement("script");

        writer.startElement("div", null);
        writer.writeText("text", null);
        writer.endElement("div");

        writer.endElement("body");

        assertEquals(3, state.getIncludes().get("text/javascript").size());
        assertTrue(state.getInlines().isEmpty());

        InOrder inOrder = inOrder(wrappedWriter);
        inOrder.verify(wrappedWriter).startElement("div", null);
        inOrder.verify(wrappedWriter, times(3)).startElement("script", null);
    }
https://github.com/primefaces/primefaces/issues/10845
primefaces/src/test/java/org/primefaces/application/resource/MoveScriptsToBottomResponseWriterTest.java