putyourlightson / craft-blitz-recommendations

Provides templating performance recommendations for Craft CMS.
MIT License
18 stars 1 forks source link

Getting loads of recommendations on single entry page #8

Closed tsawitzki closed 2 years ago

tsawitzki commented 2 years ago

Question

I am not sure I am getting this right: On my overview page template the plugin successfully detected loads of non-eager loaded for-loops. On my single entry page however I get loads of recommendations, where I am not sure these can be eager loaded at all.

e.g. I have a hero image that is exclusive to the entry I am rendering, through that dedicated template for the entry, like this (I am using ImagerX for the images):

<div class="exhibition-intro__hero">
    {% set image = entry.heroImage.one() %}
    {% set transform = craft.imagerx.transformImage(image, 'standardImage') %}
    <img srcset="{{ transform[0].url }} 600w,
                {{ transform[1].url }} 1200w"
        sizes="50vw"
        src="{{ transform[0].url }}"
        alt="{{ entry.title }}"
        class="exhibition-intro__img"
                width="{{ image.width }}"
                height="{{ image.height }}">
    <span class="exhibition-intro__credit">{{ image.title }}</span>
</div>

The plugin says I should eager load the heroImage. From what I understand, there is no need here to load anything eagerly as it is one straight request to that asset within the entry I am in anyway.

Can you give me a hint on that, is the plugin just searching for suspicious calls to .one() or did I miss a crucial point in the whole eager loading approach?

bencroker commented 2 years ago

This sounds a lot like the question that was asked in https://github.com/putyourlightson/craft-blitz-recommendations/issues/3, hopefully that'll help clarify things for you.

bencroker commented 2 years ago

Version 2.1.0 improves the behaviour of hints, see https://putyourlightson.com/articles/ballroom-blitz

tsawitzki commented 2 years ago

Perfect, thank you! Looking forward to check out the new versions.