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

Unnecessary loading image for gallery cover twice? #111

Open
eugeneandrienko opened this issue Aug 24, 2020 · 0 comments
Open

Unnecessary loading image for gallery cover twice? #111

eugeneandrienko opened this issue Aug 24, 2020 · 0 comments

Comments

@eugeneandrienko
Copy link
Contributor

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

<div class="gallery-cover" style="background-image: url('{{ cover.generate_thumbnail("x900") }}'), url('{{ cover.generate_thumbnail("x150") }}');"></div>
{% else %}
<div class="gallery-cover" style="background-image: url('{{ cover.generate_thumbnail("x1366") }}'), url('{{ cover.generate_thumbnail("x900") }}');"></div>

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.

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

1 participant