• Resolved HolidayMonk

    (@holidaymonk)


    Hi Johannes,

    First of all thank you for this very lightweight gallery plugin. My only request for you to make the scripts load on page when used. Now it loads on all pages whether it’s used or not.

    In the above link I have used Gutenberg Blocks by Kadence Blocks(gallery module) where it load its scripts only in the page used. I want to migrate to your plugin.

    I am not a coder, hope you can make this happen.

    Thanks & Regards,
    Prakash

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Johannes Kinast

    (@goaroundagain)

    Hi Prakash,

    My plugin loads only the necessary script and style if there is a Gallery Block or Image Block on the page present. If you have for example an Image Block on every page, it will load the script and style on ever page.

    Thread Starter HolidayMonk

    (@holidaymonk)

    Hi Johannes,

    I checked again and found that,

    if we have images in a page then the baguettebox css and js will load in spite of the gallery link is set to none.

    For example: https://astra.us3.instawp.xyz/ (loaded css and js from CDN)
    In this website the css and js loads in all pages except contact page since contact page doesn’t have images.

    Sorry to bother you. Due to Google Core Web Vitals, we need to think of every single bits and pieces.

    Regards,
    Prakash

    • This reply was modified 3 years, 2 months ago by HolidayMonk.
    • This reply was modified 3 years, 2 months ago by HolidayMonk.
    Plugin Author Johannes Kinast

    (@goaroundagain)

    That is correct. The plugin does not check if there is really a linked image. It just checks if there is a supported Block. See: https://github.com/goaround/gallery-block-lightbox/blob/af7a096f3b6134662edca2ba7cfe63d8ce68a38a/gallery-block-lightbox.php#L20

    I would like to keep the plugin as simple as possible. It would be possible to check if there is really a linked Gallery/Image Block, but this would make the code much more complicated, error-prone and the server-side performance would suffer. Therefore, I decided to only check if a supported Block is present. This results in more false positive, but there are better than false negatives ;).

    If you need this behaviour, feel free to fork my plugin.

    Thread Starter HolidayMonk

    (@holidaymonk)

    Thank you soo much for the quick response and positive support. I will use the plugin as it is.

    Thanks again..????

    Plugin Author Johannes Kinast

    (@goaroundagain)

    I even think you could use the Lightbox here https://astra.us3.instawp.xyz/ at least for the Gallery before *Latest posts*.

    It’s not perfect for the Google Core Web Vitals but the baguettBox.js script & style is very lightweight and there is no dependency e.g. to jQuery. The script and style will also be cached by the browser. If your visitors browses through multiple sites, the impact will be very very small.

    Thread Starter HolidayMonk

    (@holidaymonk)

    The reason I liked your plugin is – it’s very light and no dependency to jQuery. Will stick on to this plugin.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Load css and js only when used’ is closed to new replies.