Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] load lightgallery js on demand #1382

Closed
wu0407 opened this issue Nov 6, 2024 · 1 comment
Closed

[FEATURE] load lightgallery js on demand #1382

wu0407 opened this issue Nov 6, 2024 · 1 comment
Labels
new feature New feature

Comments

@wu0407
Copy link
Contributor

wu0407 commented Nov 6, 2024

Describe the feature you want 描述你的功能需求

The lightgallery resource is large, so need to optimize loading speed.
It is very difficult to determine whether there is an image in the summary of the homepage on the render.
But It is easy to determine whether there is an image on the article page.
There are many pits about Scracth Store and render cache on the Hugo server. https://discourse.gohugo.io/t/strange-behavior-with-scratch-variable/52288/11?u=xiao_qing

So The best method is to load it on demand from the front end.

Useful reference 有价值的参考

No response

@wu0407 wu0407 added the new feature New feature label Nov 6, 2024
@HEIGE-PCloud
Copy link
Owner

I think the easiest fix is to just mark these scripts as deferred

{{- $source := $cdn.lightgalleryCSS | default "lib/lightgallery/lightgallery.min.css" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}}
{{- $source := $cdn.lightgalleryJS | default "lib/lightgallery/lightgallery.min.js" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
{{- $source := $cdn.lightgalleryThumbnailJS | default "lib/lightgallery/lg-thumbnail.min.js" -}}

hodory pushed a commit to hodory/DoIt that referenced this issue Dec 16, 2024
wu0407 pushed a commit to wu0407/DoIt that referenced this issue Dec 18, 2024
Jatin794 pushed a commit to Jatin794/bog that referenced this issue Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature
Projects
None yet
Development

No branches or pull requests

2 participants