Answers.Body: <p>I usually like to use the <code>.find()</code> method and then you can pass in an object in your twig with criteria for the query. This is an example of eager-loading and relatedTo.</p>
  
  <pre><code>{% set entries = craft.entries.find({
      section: 'articles',
      with: ['featuredImage'],
      limit: 4,
      relatedTo: category
  }) %}
  </code></pre>
  
  <p>Let me know if this helps at all otherwise I'd be happy to dig into your use case more.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-22T15:14:16.397Z
Answers.LastActivityDate: 2018-01-22T16:39:42.313Z
Answers.LastEditDate: 2018-01-22T16:39:42.313Z
Answers.UserDisplayName: mcclaskiem
Body: <p>For a website I'm building for a client I've build a navigation where on hover an image changes dynamically to the image assigned to the entry. See this page for a better understanding: <a href="http://sandmandance.com/dev/projects/performance" rel="nofollow noreferrer">http://sandmandance.com/dev/projects/performance</a></p>
  
  <p>It all works fine but at first page load the images are only loading when hovering over the navigation which causes a small glitch. What I'd like to do (and seems like the easiest solution) is to load all the assets on page load using Eager-Loading.</p>
  
  <p>Thing is.. I can't seem to combine it with relatedTo(category). So in short; how can I combine Eager-Loading and relatedTo(category) in a way it works?</p>
  
Tags: <relatedto><eager-loading>
Title: Combine Eager-Loading and relatedTo(category)
ThreadText: # Combine Eager-Loading and relatedTo(category)
  
  (Asked by: username_0 on 2018-01-22)
  
  For a website I'm building for a client I've build a navigation where on hover an image changes dynamically to the image assigned to the entry. See this page for a better understanding: <http://sandmandance.com/dev/projects/performance>
  
  It all works fine but at first page load the images are only loading when hovering over the navigation which causes a small glitch. What I'd like to do (and seems like the easiest solution) is to load all the assets on page load using Eager-Loading.
  
  Thing is.. I can't seem to combine it with relatedTo(category). So in short; how can I combine Eager-Loading and relatedTo(category) in a way it works?
  
  **Tags:** relatedto, eager-loading
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-01-22. Score: 1
  
  I usually like to use the `.find()` method and then you can pass in an object in your twig with criteria for the query. This is an example of eager-loading and relatedTo.
  
  ```
  {% set entries = craft.entries.find({
      section: 'articles',
      with: ['featuredImage'],
      limit: 4,
      relatedTo: category
  }) %}
  
  ```
  
  Let me know if this helps at all otherwise I'd be happy to dig into your use case more.
  
  
  ---
  
  