diff options
| author | BigCoke233 <hi@guhub.cn> | 2026-01-16 23:59:31 +0800 |
|---|---|---|
| committer | BigCoke233 <hi@guhub.cn> | 2026-01-16 23:59:31 +0800 |
| commit | bcd509c540632b6524a8dd87a4613e64ed0402f6 (patch) | |
| tree | d55ed80119c7a72a07d7eed40c7750f63b22d42a | |
| parent | 9fab8272ca7d94841c3543eab8a4c1e91dd76b85 (diff) | |
perf: load aplayer resources only when needed
| -rw-r--r-- | content/posts/weekly/31.md | 1 | ||||
| -rw-r--r-- | content/posts/weekly/40.md | 1 | ||||
| -rw-r--r-- | layouts/_partials/head/css.html | 6 | ||||
| -rw-r--r-- | layouts/_partials/scripts/aplayer-js.html | 2 |
4 files changed, 8 insertions, 2 deletions
diff --git a/content/posts/weekly/31.md b/content/posts/weekly/31.md index 917ea1ce..c45bf92d 100644 --- a/content/posts/weekly/31.md +++ b/content/posts/weekly/31.md @@ -18,6 +18,7 @@ endnotes: - 封面图上的摄像头,像不像停在电线杆上的鸟呢? aliases: - /posts/weekly/31 +hasAplayer: true --- diff --git a/content/posts/weekly/40.md b/content/posts/weekly/40.md index 9794bc81..8c72358d 100644 --- a/content/posts/weekly/40.md +++ b/content/posts/weekly/40.md @@ -17,6 +17,7 @@ endnotes: - 封面图自摄,设备为 iPhone 15 Pro aliases: - /posts/weekly/40 +hasAplayer: true --- diff --git a/layouts/_partials/head/css.html b/layouts/_partials/head/css.html index f7fa9a9c..37e0002a 100644 --- a/layouts/_partials/head/css.html +++ b/layouts/_partials/head/css.html @@ -1,6 +1,8 @@ <!-- Aplayer --> -{{ with resources.Get "css/aplayer.css" }} -<style>{{ .Content | safeCSS }}</style> +{{ if and (not .IsHome) .Params.hasAplayer }} + {{ with resources.Get "css/aplayer.css" }} + <style>{{ .Content | safeCSS }}</style> + {{ end }} {{ end }} <!-- Pagefind --> diff --git a/layouts/_partials/scripts/aplayer-js.html b/layouts/_partials/scripts/aplayer-js.html index e777b0c9..2aa3db3d 100644 --- a/layouts/_partials/scripts/aplayer-js.html +++ b/layouts/_partials/scripts/aplayer-js.html @@ -1,3 +1,4 @@ +{{ if and (not .IsHome) .Params.hasAplayer }} <script> document.addEventListener("DOMContentLoaded", function () { const lazyPlayers = document.querySelectorAll(".lazy-aplayer"); @@ -43,3 +44,4 @@ document.addEventListener("DOMContentLoaded", function () { lazyPlayers.forEach(player => observer.observe(player)); }); </script> +{{ end }} |
