I am trying to get to grips with Eager Loading. I have the following code:
{% for article in entry.relatedArticles %}
<div class="c-card // l-card--third">
<a href="{{ article.url }}">
<img src="{{ article.bannerImage.first().getUrl('cardImage') }}" alt="{{ article.title }}" class="c-card__img">
<div class="c-card__bar // js_fitcontent">
{% set array = article.title|split(' ', 2) %}
<p class="c-card__title"><strong>{{ attribute(array, 0) }}</strong> {{ attribute(array, 1) }}</p>
<p class="c-card__msg // js-fittext">Posted on {{ helpers.date_formatted(entry.postDate) }}</p>
</div>
<div class="c-card__over">
<div class="c-card__over-content">
<div class="animate">
<p class="c-card__title"><strong>Related</strong> Article</p>
<p class="c-card__msg // half-margin-bottom">
<strong>{{ article.title }}</strong><br />
<time datetime="{{ entry.postDate|date('Y-m-d H:i:s') }}" class="date">
<svg role="img" class="icon // icon-date" title="Date Icon">
<use xlink:href="/assets/img/icons.svg#icon-date"></use>
</svg>{{ helpers.date_formatted(entry.postDate) }}
</time>
</p>
<p class="btn // btn--sub">Read Article</p>
</div>
</div>
</div>
</a>
</div>
{% endfor %}
Looking on the console this combined with the other page requests totals 76 requests. I thought I perhaps should add some eager loading 9at least tot he image transform) So I tried the following:
{% for article in entry.relatedArticles.withTransforms('cardImage') %}
<div class="c-card // l-card--third">
<a href="{{ article.url }}">
<img src="{{ article.bannerImage.first().getUrl('cardImage') }}" alt="{{ article.title }}" class="c-card__img">
<div class="c-card__bar // js_fitcontent">
{% set array = article.title|split(' ', 2) %}
<p class="c-card__title"><strong>{{ attribute(array, 0) }}</strong> {{ attribute(array, 1) }}</p>
<p class="c-card__msg // js-fittext">Posted on {{ helpers.date_formatted(entry.postDate) }}</p>
</div>
<div class="c-card__over">
<div class="c-card__over-content">
<div class="animate">
<p class="c-card__title"><strong>Related</strong> Article</p>
<p class="c-card__msg // half-margin-bottom">
<strong>{{ article.title }}</strong><br />
<time datetime="{{ entry.postDate|date('Y-m-d H:i:s') }}" class="date">
<svg role="img" class="icon // icon-date" title="Date Icon">
<use xlink:href="/assets/img/icons.svg#icon-date"></use>
</svg>{{ helpers.date_formatted(entry.postDate) }}
</time>
</p>
<p class="btn // btn--sub">Read Article</p>
</div>
</div>
</div>
</a>
</div>
{% endfor %}
However, this also still results in 76 requests.
So my question is this; Have I misunderstood when I need to use Eager Loading? or is my code incorrect and thus eager loading isn't actually taking place?
Thanks.