Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

System jQuery at bottom conflicts with Debug Panel

Solved by Alexander Kim View solution

Started by Alexander Kim 9 years ago · 2 replies · 831 views
9 years ago

Can i use something like that:

TWIG
    {% block javascripts %}
        {# condition if debugbar plugin is on, put jquery in a head section, otherwise - bottom #}
        {% do assets.addJs('jquery', { 'priority':'101' }) %}
    {% endblock %}
    {{ assets.js() }}

Can i use some kind of conditions to put system jQuery at top or bottom depending on Debugbar plugin status on/off?

9 years ago Solution

In case if someone else needs this:

TWIG
        {# if debugger is enabled, load jquery to head, if not - to bottom #}
        {% if system.debugger.enabled %}
            {% do assets.addJs('jquery', { 'priority':'101' }) %}
        {% else %}
            {% do assets.addJs('jquery', { 'priority':'101', 'group':'bottom' }) %}
        {% endif %}
👍 1
5 years ago

use pipeline option can be necessary for some themes (like QUARK)

TWIG
{% do assets.addJs('jquery', {'priority': 101, 'pipeline':false, group:'bottom'}) %}
👍 1

Suggested topics

Topic Participants Replies Views Activity
Support · by webmasterodp, 1 week ago
4 169 1 week ago
Support · by nwhitfield, 1 week ago
2 145 1 week ago
Support · by stell, 3 weeks ago
5 379 2 weeks ago
Support · by gravinator, 1 month ago
5 571 2 weeks ago
Support · by Gravver, 3 weeks ago
6 356 3 weeks ago