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

Include Lightbox js only when gallery is used on that page #2

Open
ozgurhaber opened this issue Jul 14, 2022 · 7 comments
Open

Include Lightbox js only when gallery is used on that page #2

ozgurhaber opened this issue Jul 14, 2022 · 7 comments

Comments

@ozgurhaber
Copy link

Hi. The plugin is nice and I want to use it. But the plugin js,css files are loading on all pages. It's not necessary.

How can I make it only load on pages with a wordpress gallery? If there is a gallery in posts, load the plugin js,css files? thanks

@arjhun
Copy link

arjhun commented Sep 22, 2022

It's think it should be oke, if you look at the networking I think it is cached when loaded. So no problem....

@ozgurhaber
Copy link
Author

Hi. I didn't say there was a problem. I think it is unnecessary to load it on all pages. It would be better to load only on pages with galleries. thanks

@arjhun
Copy link

arjhun commented Sep 22, 2022

It's not loaded on all pages :) that is what i was saying ;)

@ozgurhaber
Copy link
Author

ozgurhaber commented Sep 23, 2022

It's not loaded on all pages :) that is what i was saying ;)

I guess you have never used this plugin. :) js and css files are loading on all pages.

@arjhun
Copy link

arjhun commented Sep 23, 2022

Sorry I should elaborate.... The script and css is at a minimum mem cached by the browser. So only downloaded once per cached session, and than it is only really fully executed when it finds what it's looking for, very small overhead. Looking dynamically for galleries and then lazily server side injecting the script en executing it is way more overhead! Dont forget it works on all images that are a link!

@arjhun
Copy link

arjhun commented Sep 23, 2022

image

@ozgurhaber
Copy link
Author

Sorry I should elaborate.... The script and css is at a minimum mem cached by the browser. So only downloaded once per cached session, and than it is only really fully executed when it finds what it's looking for, very small overhead. Looking dynamically for galleries and then lazily server side injecting the script en executing it is way more overhead! Dont forget it works on all images that are a link!

I already use cache and the pages are loaded as html. So I don't think these plugin files need to be loaded on all pages.
I know it's browser cached. but It is unnecessary to load on non-image pages.

Example: I used to use this plugin for "NextGEN Gallery" before. https://wordpress.org/plugins/nextgen-gallery-optimizer/

this was not allowing it to load on all pages. I was looking for a method similar to this. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants