Git Product home page Git Product logo

Comments (2)

ganeshh123 avatar ganeshh123 commented on June 26, 2024 1

I've found a small workaround for now. It doesn't implement lazy loading, but it reduces the load time for large galleries. The large load comes from loading all the images to measure their height and width for Photoswipe.

If you have thumbnail images, you can switch the code to use the thumbnail's dimensions to figure out an aspect ratio, set a fixed large enough width and calculate a height from it.

Lines 47-60 of load-photoswipe.js

// load the image to check its dimensions
// update the item as soon as w and h are known (check every 30ms)
var img = new Image(); 
img.src = $img.attr('src');
var wait = setInterval(function() {
var w = img.naturalWidth,
	h = img.naturalHeight;
if (w && h) {
	clearInterval(wait);
	ratio = w/h
	item.w = 1920;
	item.h = 1920/ratio;
}
}, 30);

from hugo-easy-gallery.

iranzo avatar iranzo commented on June 26, 2024

There's a library call b-lazy that allows to do lazy loading of almost anything: https://dinbror.dk/blog/blazy/

from hugo-easy-gallery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.