From 4d8b078e99a081d3a9f205e074f7cb3327e57ab2 Mon Sep 17 00:00:00 2001 From: Doom Date: Sun, 28 Dec 2025 14:21:53 +0200 Subject: [PATCH] Prevent duplicate script injection in tabbed_block plugin The tabbed_block plugin was injecting the same JavaScript code every time a tabbed block was rendered. On pages with multiple tabbed blocks, this resulted in duplicate script tags and function definitions. This change uses a context flag to ensure the script is only included once per page, reducing page size and avoiding redundant code. --- plugins/tabbed_block.rb | 50 ++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/plugins/tabbed_block.rb b/plugins/tabbed_block.rb index 508dbf54940f..59abdab18865 100644 --- a/plugins/tabbed_block.rb +++ b/plugins/tabbed_block.rb @@ -31,28 +31,36 @@ def render(context) site = context.registers[:site] converter = site.find_converter_instance(::Jekyll::Converters::Markdown) - <<~MARKUP - -
+ + SCRIPT + end + + <<~MARKUP + #{script}
#{render_tabbed_block(vars: vars, converter: converter)}
MARKUP