diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html
index 03d5926..0bc62dc 100644
--- a/layouts/partials/scripts.html
+++ b/layouts/partials/scripts.html
@@ -1,104 +1,16 @@
-{{- $jsTheme := resources.Get "js/theme.js" | resources.ExecuteAsTemplate "theme.js" . -}}
-{{- $jsMenu := resources.Get "js/menu.js" -}}
-{{- $jsTabs := resources.Get "js/tabs.js" -}}
-{{- $jsLang := resources.Get "js/lang.js" -}}
-{{- $jsCodeCopy := resources.Get "js/code-copy.js" -}}
-{{- $jsFileTree := resources.Get "js/filetree.js" -}}
-{{- $jsSidebar := resources.Get "js/sidebar.js" -}}
-{{- $jsBackToTop := resources.Get "js/back-to-top.js" -}}
-
-{{- $scripts := slice $jsTheme $jsMenu $jsCodeCopy $jsTabs $jsLang $jsFileTree $jsSidebar $jsBackToTop | resources.Concat "js/main.js" -}}
-{{- if hugo.IsProduction -}}
- {{- $scripts = $scripts | minify | fingerprint -}}
-{{- end -}}
-
-
+{{/* Core scripts (theme, menu, tabs, etc.) */}}
+{{- partial "scripts/core.html" . -}}
{{/* Search */}}
-{{- if (site.Params.search.enable | default true) -}}
- {{- $searchType := site.Params.search.type | default "flexsearch" -}}
- {{- if eq $searchType "flexsearch" -}}
- {{- $jsSearchScript := printf "%s.search.js" .Language.Lang -}}
- {{- $jsSearch := resources.Get "js/flexsearch.js" | resources.ExecuteAsTemplate $jsSearchScript . -}}
- {{- if hugo.IsProduction -}}
- {{- $jsSearch = $jsSearch | minify | fingerprint -}}
- {{- end -}}
- {{- $flexSearchJS := resources.Get "lib/flexsearch/flexsearch.bundle.min.js" | fingerprint -}}
-
-
- {{- else -}}
- {{- warnf `search type "%s" is not supported` $searchType -}}
- {{- end -}}
-{{- end -}}
+{{- partial "scripts/search.html" . -}}
{{/* Mermaid */}}
{{/* FIXME: need to investigate .Page.Store hasMermaid is set for homepage */}}
{{- if and (.Page.Store.Get "hasMermaid") (not .Page.IsHome) -}}
- {{- $mermaidJS := resources.Get "lib/mermaid/mermaid.min.js" | fingerprint -}}
-
-
+ {{- partial "scripts/mermaid.html" . -}}
{{- end -}}
{{/* KaTex */}}
{{- if .Page.Params.math -}}
- {{- $katexCSS := resources.Get "lib/katex/katex.min.css" | fingerprint -}}
- {{- $katexJS := resources.Get "lib/katex/katex.min.js" | fingerprint -}}
- {{- $mhchemJS := resources.Get "lib/katex/mhchem.min.js" | fingerprint -}}
- {{- $katexAutoRenderJS := resources.Get "lib/katex/auto-render.min.js" | fingerprint -}}
-
-
-
-
- {{ $katexFonts := resources.Match "lib/katex/fonts/*" }}
- {{- range $katexFonts -}}
- {{ .Publish }}
- {{- end -}}
-
-{{ end }}
+ {{- partial "scripts/katex.html" . -}}
+{{- end -}}
diff --git a/layouts/partials/scripts/core.html b/layouts/partials/scripts/core.html
new file mode 100644
index 0000000..4fce55c
--- /dev/null
+++ b/layouts/partials/scripts/core.html
@@ -0,0 +1,14 @@
+{{- $jsTheme := resources.Get "js/theme.js" | resources.ExecuteAsTemplate "theme.js" . -}}
+{{- $jsMenu := resources.Get "js/menu.js" -}}
+{{- $jsTabs := resources.Get "js/tabs.js" -}}
+{{- $jsLang := resources.Get "js/lang.js" -}}
+{{- $jsCodeCopy := resources.Get "js/code-copy.js" -}}
+{{- $jsFileTree := resources.Get "js/filetree.js" -}}
+{{- $jsSidebar := resources.Get "js/sidebar.js" -}}
+{{- $jsBackToTop := resources.Get "js/back-to-top.js" -}}
+
+{{- $scripts := slice $jsTheme $jsMenu $jsCodeCopy $jsTabs $jsLang $jsFileTree $jsSidebar $jsBackToTop | resources.Concat "js/main.js" -}}
+{{- if hugo.IsProduction -}}
+ {{- $scripts = $scripts | minify | fingerprint -}}
+{{- end -}}
+
diff --git a/layouts/partials/scripts/katex.html b/layouts/partials/scripts/katex.html
new file mode 100644
index 0000000..fe5604e
--- /dev/null
+++ b/layouts/partials/scripts/katex.html
@@ -0,0 +1,33 @@
+{{/* KaTex */}}
+{{- $katexCSS := resources.Get "lib/katex/katex.min.css" | fingerprint -}}
+{{- $katexJS := resources.Get "lib/katex/katex.min.js" | fingerprint -}}
+{{- $mhchemJS := resources.Get "lib/katex/mhchem.min.js" | fingerprint -}}
+{{- $katexAutoRenderJS := resources.Get "lib/katex/auto-render.min.js" | fingerprint -}}
+
+
+
+
+{{ $katexFonts := resources.Match "lib/katex/fonts/*" }}
+{{- range $katexFonts -}}
+ {{ .Publish }}
+{{- end -}}
+
diff --git a/layouts/partials/scripts/mermaid.html b/layouts/partials/scripts/mermaid.html
new file mode 100644
index 0000000..148d975
--- /dev/null
+++ b/layouts/partials/scripts/mermaid.html
@@ -0,0 +1,33 @@
+{{/* Mermaid */}}
+
+{{- $mermaidJS := resources.Get "lib/mermaid/mermaid.min.js" | fingerprint -}}
+
+
diff --git a/layouts/partials/scripts/search.html b/layouts/partials/scripts/search.html
new file mode 100644
index 0000000..b71e890
--- /dev/null
+++ b/layouts/partials/scripts/search.html
@@ -0,0 +1,16 @@
+{{/* Search */}}
+{{- if (site.Params.search.enable | default true) -}}
+ {{- $searchType := site.Params.search.type | default "flexsearch" -}}
+ {{- if eq $searchType "flexsearch" -}}
+ {{- $jsSearchScript := printf "%s.search.js" .Language.Lang -}}
+ {{- $jsSearch := resources.Get "js/flexsearch.js" | resources.ExecuteAsTemplate $jsSearchScript . -}}
+ {{- if hugo.IsProduction -}}
+ {{- $jsSearch = $jsSearch | minify | fingerprint -}}
+ {{- end -}}
+ {{- $flexSearchJS := resources.Get "lib/flexsearch/flexsearch.bundle.min.js" | fingerprint -}}
+
+
+ {{- else -}}
+ {{- warnf `search type "%s" is not supported` $searchType -}}
+ {{- end -}}
+{{- end -}}