In my template, I have an includeJSFile that loads properly on the first load, but disappears on subsequent loads.

The includeJSFile is outside the caching tags, so I'm not sure why this is still happening. There's no caching in my layout.twig as well.

I also have a variable set in my template that I'm calling in via the includeJS tag (placed outside of the cache tags), and that seems to be having the same issue as well. Any idea to resolve this? Here's the setup.

{% extends "_layout" %}
{% block content %}
    {% cache globally using key craft.request.path %}

    {% set entries = craft.entries({
        section: 'MY-SECTION',
        with: [
        'MY-ASSET-FIELD'
        ]
    }) %}

    -- MY ENTRY LOOP -- 

{% endcache %}

{% includeJsFile 'MY-JS.js' %}

{% set MY-JS-VARIABLE %}

    -- MY JS CONTENT THAT LOOPS THROUGH SECTION ENTRIES TO INSTANTIATE MY JS OBJECTS --

{% endset %}

{% includeJs MY-JS-CONTENT %}
{% endblock %}

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.