Psycojoker / prosopopee

a static website generator to make beautiful customizable pictures galleries that tell a story
http://prosopopee.readthedocs.org
GNU General Public License v3.0
327 stars 56 forks source link

Unnecessary loading image for gallery cover twice? #111

Open eugeneandrienko opened 4 years ago

eugeneandrienko commented 4 years ago

I do not clearly understand this lines of code added in this commit f12587b9277d1fdaea22a02f9c774ed7825fac74:

https://github.com/Psycojoker/prosopopee/blob/0c6e83fd7d705091f4f5a00499547c9a95ff820b/prosopopee/themes/exposure/templates/index.html#L56-L58

Based on the information from MDN about background-image CSS property — browser loads first specified image in this property and puts it on the top of the «stack» of images. After that it loads second image from background-image property — and puts it behind first image.

So, looks like we load (and process with gm) the same image for the gallery cover on main page twice. But we can see only first specified image (x1366), because second (x900) is smaller and fully covered by first image.

I've tested — in my installation of prosopopee with removed loading of first (bigger) image — I've got 4.21 Mb of data transferred with all request when loading main page. And I waiting 196 ms before all requests completed.

With default index.html, without my changes — I've got 14.84 Mb and 519 ms. Of course, all tests were without browser cache.

If twice image loading is not needed — I can submit a pull request with removed loading of bigger (first) image for gallery cover.