private void writeResourceTag(final UrlMode urlMode, final Container resource,
final WebResourceFormatter formatter, final Writer writer, boolean isDeferJsAttributeEnabled,
boolean writingPrefetchLinks) {
PluginUrlResource urlResource = resource.getPluginUrlResource();
String formattedResource;
if (formatter instanceof JavascriptWebResource) {
Map<String, String> params = resource.getResourceUrl().getParams();
Map<String, String> attributes = new LinkedHashMap<>(urlResource.getParams().all());
if (config.useAsyncAttributeForScripts()) {
params.put(Config.ASYNC_SCRIPT_PARAM_NAME, "true");
attributes.put(Config.ASYNC_SCRIPT_PARAM_NAME, "");
}
attributes.put(Config.INITIAL_RENDERED_SCRIPT_PARAM_NAME, "");
formattedResource = ((JavascriptWebResource) formatter).formatResource(urlResource.getStaticUrl(urlMode), attributes, isDeferJsAttributeEnabled);
} else {
formattedResource = formatter.formatResource(urlResource.getStaticUrl(urlMode), urlResource.getParams().all());
}
if (!writingPrefetchLinks && config.isBatchContentTrackingEnabled()) {
formattedResource = BatchResourceContentsWebFormatter.insertBatchResourceContents(resource, formattedResource);
}
writeContentAndSwallowErrors(writer, formattedResource);
}