From d90767eac3b89dbb9cdc5b4b254ff553cc6a826c Mon Sep 17 00:00:00 2001 From: Helena Rasche Date: Tue, 5 Mar 2024 16:17:32 +0100 Subject: [PATCH 1/4] clean up bundle, list seems unused, mermaid goes conditional --- _config.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/_config.yml b/_config.yml index 07848b02b82ace..3baa0cece16a4f 100644 --- a/_config.yml +++ b/_config.yml @@ -49,14 +49,13 @@ javascript_bundles: main: preload: true resources: - - assets/js/jquery.slim.min.js - - assets/js/popper.min.js - - assets/js/bootstrap.min.js - - assets/js/bootstrap-toc.min.js - - assets/js/clipboard.min.js - - assets/js/list.min.js - - assets/js/mermaid@10.6.1.js + - assets/js/jquery.slim.min.js # Mandatory for bootstrap. + - assets/js/popper.min.js # Everywhere, dropdown menu. + - assets/js/bootstrap.min.js # Everywhere + - assets/js/bootstrap-toc.min.js # Only tutorials, faqs + - assets/js/clipboard.min.js # Used on anything with a pre - assets/js/main.js + # - assets/js/list.min.js # Potentially unused? # Conversion markdown: kramdown From 3c739af6857024052727bbceca78e0dc9cfe62ea Mon Sep 17 00:00:00 2001 From: Helena Rasche Date: Tue, 5 Mar 2024 16:17:46 +0100 Subject: [PATCH 2/4] Conditional loading of mermaid --- _layouts/base.html | 13 +++++++++---- _plugins/jekyll-bundler.rb | 2 +- _plugins/jekyll-mathjax.rb | 5 ++++- bin/commit-cache-update.rb | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/_layouts/base.html b/_layouts/base.html index af34f295ec1a59..b64eeca8ffd99e 100644 --- a/_layouts/base.html +++ b/_layouts/base.html @@ -21,7 +21,7 @@ - {% if page.mathjax %} + {% if page.js_requirements.mathjax %} {% endif %} @@ -68,8 +68,13 @@ {% include _includes/default-footer.html %} {{ 'main' | load_bundle }} - {% if page.mathjax %} - - {% endif %} + + {% if page.js_requirements.mathjax %} + + {% endif %} + {% if page.js_requirements.mermaid %} + + + {% endif %} diff --git a/_plugins/jekyll-bundler.rb b/_plugins/jekyll-bundler.rb index 48fad37354f63c..361a18a4e53ed8 100644 --- a/_plugins/jekyll-bundler.rb +++ b/_plugins/jekyll-bundler.rb @@ -64,7 +64,7 @@ def bundle_preloads_prod end bundles.map do |_name, bundle| - bundle_path = "#{baseurl}#{bundle['path']}?v=#{bundle['timestamp']}" + bundle_path = "#{baseurl}#{bundle['path']}" "" end.join("\n") end diff --git a/_plugins/jekyll-mathjax.rb b/_plugins/jekyll-mathjax.rb index 0510830a614a2b..acbe2f78026b70 100644 --- a/_plugins/jekyll-mathjax.rb +++ b/_plugins/jekyll-mathjax.rb @@ -1,3 +1,6 @@ Jekyll::Hooks.register :pages, :post_init do |page| - page.data['mathjax'] = page.content =~ /\$\$/ + page.data['js_requirements'] = { + 'mathjax' => page.content =~ /\$\$/, + 'mermaid' => page.content =~ /```mermaid/ || page.content =~ /pre class="mermaid"/ || page.data['layout'] == 'workflow-list', + } end diff --git a/bin/commit-cache-update.rb b/bin/commit-cache-update.rb index 1cda20b0768e81..c00f8e0f3636c6 100644 --- a/bin/commit-cache-update.rb +++ b/bin/commit-cache-update.rb @@ -1,5 +1,5 @@ require 'jekyll' -require './_plugins/gtn/mod.rb' +require './_plugins/gtn/mod' # Write the commit log Gtn::ModificationTimes.generate_cache From f3f095d69ea6748f1db6be0fd3a7883489b86015 Mon Sep 17 00:00:00 2001 From: Helena Rasche Date: Tue, 5 Mar 2024 16:40:01 +0100 Subject: [PATCH 3/4] defer some more --- _config.yml | 2 ++ _layouts/home.html | 2 +- _plugins/jekyll-bundler.rb | 11 +++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/_config.yml b/_config.yml index 3baa0cece16a4f..9b0a6ea2690999 100644 --- a/_config.yml +++ b/_config.yml @@ -48,6 +48,8 @@ javascript_bundles: - assets/js/theme.js main: preload: true + defer: true + async: true resources: - assets/js/jquery.slim.min.js # Mandatory for bootstrap. - assets/js/popper.min.js # Everywhere, dropdown menu. diff --git a/_layouts/home.html b/_layouts/home.html index 54111a00d754f4..3479a6c9b1a9ac 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -248,7 +248,7 @@

Meet & Join the Community!

GTN Toots

- + " + "" end.join("\n") end @@ -99,8 +103,11 @@ def load_bundle_production(name) raise "Bundle #{name} not found in site config" if bundle.nil? baseurl = @context.registers[:site].config['baseurl'] + attrs = "" + attrs += " async" if bundle['async'] + attrs += " defer" if bundle['defer'] bundle_path = "#{baseurl}#{bundle['path']}?v=#{bundle['timestamp']}" - "" + "" end end end From 700d5b6d39e093860d057cd4de3154b65522692e Mon Sep 17 00:00:00 2001 From: Helena Rasche Date: Wed, 6 Mar 2024 09:52:13 +0100 Subject: [PATCH 4/4] no timestamp, better bundle name --- _plugins/jekyll-bundler.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_plugins/jekyll-bundler.rb b/_plugins/jekyll-bundler.rb index f7d1548362c812..d6df8e672d0c12 100644 --- a/_plugins/jekyll-bundler.rb +++ b/_plugins/jekyll-bundler.rb @@ -13,7 +13,7 @@ bundle = resources['resources'].map { |f| File.read(f) }.join("\n") hash = Digest::MD5.hexdigest(bundle)[0..7] site.config['javascript_bundles'][name]['hash'] = hash - site.config['javascript_bundles'][name]['path'] = "/assets/js/bundle.#{hash}.js" + site.config['javascript_bundles'][name]['path'] = "/assets/js/bundle.#{name}.#{hash}.js" Jekyll.logger.info "Analysing JS Bundle #{name} => #{bundle_timestamp} / #{hash}" end @@ -106,7 +106,7 @@ def load_bundle_production(name) attrs = "" attrs += " async" if bundle['async'] attrs += " defer" if bundle['defer'] - bundle_path = "#{baseurl}#{bundle['path']}?v=#{bundle['timestamp']}" + bundle_path = "#{baseurl}#{bundle['path']}" "" end end