Method RenderKitUtils.renderPassThroughAttributesOptimized(FacesContext, UIComponent, Map<String, ComponentAttribute>) is for encoding attributes of components merged together with behavior chains (where applicable). ComponentAttribute class is a static class containing metadata.
If it doesn't work for you, then maybe you've provided incomplete metadata?
On the placement question: you can put this tag in the element before any other element that renders text, so that the sequence is as follows:
- starting tag
- attributes (either specified inline or via pass-through)
- text/nested tags
Another limitation is that you cannot have two different attributes with the same name in the same element - that's XML restriction. CDK should handle this correctly for a mix of inline/pass-through tag attributes, but it cannot validate direct calls to ResponseWriter.