From 15a8b1de61c12a8f6b50dd44a391e03abb149c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 6 Jan 2025 10:03:04 +0100 Subject: [PATCH] Update Batch.md --- content/en/functions/js/Batch.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/content/en/functions/js/Batch.md b/content/en/functions/js/Batch.md index 85538c29b..9960faa39 100644 --- a/content/en/functions/js/Batch.md +++ b/content/en/functions/js/Batch.md @@ -256,6 +256,12 @@ Eeach [`Resource`] will be of media type `application/javascript` or `text/css`. In a template you would typically handle one group with a given `ID` (e.g. scripts for the current section). Because of the concurrent build, this needs to be done in a [`templates.Defer`] block: +{{% note %}} +The [`templates.Defer`] acts as a synchronisation point to handle scripts added concurrently by different templates. If you have a setup with where the batch is created in one go (in one template), you don't need it. + +See [this discussion] for more. +{{% /note %}} + ```go-html-template {{ $group := .group }} {{ with (templates.Defer (dict "key" $group "data" $group )) }} @@ -320,4 +326,4 @@ console.log('entrypoints-workaround.js'); [script options]: #script-options [script]: #script [SetOptions]: #optionssetter -[with]: https://gohugo.io/functions/go-template/with/ \ No newline at end of file +[with]: https://gohugo.io/functions/go-template/with/