<p>I am having trouble pinpointing the issue but I am struggling with some of my pages taking an absolute age to load. For example;  </p>

<p><img src="https://i.sstatic.net/hcnGJ.png" alt="Slow loading example"> 
<img src="https://i.sstatic.net/SNvC3.png" alt="Slow loading example"> 
It might be a local MAMP issue, but some pages load fine and I would say these pages seem to load very slowly each time.</p>

<p>it could be related to the imager plugin (generating lots of images (srcset and sizes) but I expect this only to run in the first instance not each time. When I look in my folders (in dropbox) I can see the folders get updated by not each image file. </p>

<p>Or it could be my code and queries and setup, in particular Eager-loading.
I am struggling to get my head around this and I have so far been unable to reduce the amount of queries, this also varies on each load from between 107ish to 115ish.</p>

<p>Here is my code for this particular section. I do have related categories and images for each entry which I believe would benefit from Eager Loading, but I cannot establish if my code is correct for the eager loading?</p>

<pre><code>&lt;div class="container"&gt;
    {% set categories = craft.categories.group('cables') %}
    {% set cables = craft.entries({
            section: 'cables',
            with: [
                'cableCategory',
                'cableImage',
            ],
            order:  'title'
    }) %}

    {% for category in categories.relatedTo(cables) %}
    &lt;div class="cableGroup"&gt;
        &lt;h2 class="panel__title"&gt;{{ category }}&lt;/h2&gt;
        &lt;div class="cableGroup__description content // margin-bottomX2"&gt;
            {{ category.description }}
        &lt;/div&gt;

        &lt;ul&gt;
            {% for cable in cables.relatedTo(category) %}
            {% set image = cable.cableImage[0] ?? null %}
            &lt;li class="cable"&gt;
                &lt;a href="#{{ cable.title|camel|upper }}" data-title="{{ cable.title }} &amp;#xa;"&gt;
                    {% if image|length %}
                    {{ img.imagerSrcsetSizes(image, cable.title, '', 'thumb') }}
                    {% else %}
                        &lt;img src="/assets/img/fallback-cable-thumb.jpg" alt="No Image Available"&gt;
                    {% endif %}
                    &lt;h3 class="cable__tag"&gt;{{ cable.title }}&lt;/h3&gt;
                &lt;/a&gt;
            &lt;/li&gt;

            {% endfor %}
        &lt;/ul&gt;

        {% for cable in cables.relatedTo(category) %}
            {% include '_includes/cables/cableModal' %}
        {% endfor %}
    &lt;/div&gt;
    {% endfor %}
&lt;/div&gt;
</code></pre>

CC BY-SA 3.0
2017-03-21T19:00:35.893Z
You need to figure out if the time is being eaten by database queries (number and type) or code/PHP or a combination of both.  With devMode enabled, the SQL profiling output in the browser's console is sorted by slowest performing queries at the top.  Code profile output in `craft/storage/runtime/logs` is timestamped, so you can see where the big gaps are as the code is executing.
Brad Bell
CC BY-SA 3.0
2017-03-21T22:27:54.113Z
What do you mean by `When I look in my folders (in dropbox) I can see the folders get updated by not each image file.`? If you have the Imager config setting `cacheEnabled` = `false`, the images would be generated on every page load. My favourite way of debugging stuff like this is to just delete chunks of the templating code until I figure out what chunk takes the most time. ;)
André Elvan
CC BY-SA 3.0
2017-03-22T09:32:31.157Z
@AndréElvan cacheEnabled is on by default I believe. When I say updating. I see the green icon turn to the blue updating icon in Dropbox (but this only happens for the folders and not the image files).
Terry Upton
<performance><eager-loading><mamp>
Superslow loading of pages in Craft locally
# Superslow loading of pages in Craft locally

(Asked by: username_0 on 2017-03-21)

I am having trouble pinpointing the issue but I am struggling with some of my pages taking an absolute age to load. For example;  

 
It might be a local MAMP issue, but some pages load fine and I would say these pages seem to load very slowly each time.
it could be related to the imager plugin (generating lots of images (srcset and sizes) but I expect this only to run in the first instance not each time. When I look in my folders (in dropbox) I can see the folders get updated by not each image file. 
Or it could be my code and queries and setup, in particular Eager-loading.
I am struggling to get my head around this and I have so far been unable to reduce the amount of queries, this also varies on each load from between 107ish to 115ish.
Here is my code for this particular section. I do have related categories and images for each entry which I believe would benefit from Eager Loading, but I cannot establish if my code is correct for the eager loading?

    {% set categories = craft.categories.group('cables') %}
    {% set cables = craft.entries({
            section: 'cables',
            with: [
                'cableCategory',
                'cableImage',
            ],
            order:  'title'
    }) %}

    {% for category in categories.relatedTo(cables) %}
    
        {{ category }}
        
            {{ category.description }}
        

        
            {% for cable in cables.relatedTo(category) %}
            {% set image = cable.cableImage[0] ?? null %}
            
                
                    {% if image|length %}
                    {{ img.imagerSrcsetSizes(image, cable.title, '', 'thumb') }}
                    {% else %}
                        
                    {% endif %}
                    {{ cable.title }}
                
            

            {% endfor %}
        

        {% for cable in cables.relatedTo(category) %}
            {% include '_includes/cables/cableModal' %}
        {% endfor %}
    
    {% endfor %}

**Tags:** performance, eager-loading, mamp

> **Comments:**
> **username_1**: You need to figure out if the time is being eaten by database queries (number and type) or code/PHP or a combination of both.  With devMode enabled, the SQL profiling output in the browser's console is sorted by slowest performing queries at the top.  Code profile output in `craft/storage/runtime/logs` is timestamped, so you can see where the big gaps are as the code is executing.  
> **username_2**: What do you mean by `When I look in my folders (in dropbox) I can see the folders get updated by not each image file.`? If you have the Imager config setting `cacheEnabled` = `false`, the images would be generated on every page load. My favourite way of debugging stuff like this is to just delete chunks of the templating code until I figure out what chunk takes the most time. ;)  
> **username_0**: @AndréElvan cacheEnabled is on by default I believe. When I say updating. I see the green icon turn to the blue updating icon in Dropbox (but this only happens for the folders and not the image files).  

---

## 0 answers

