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

How to properly load js files in the footer?

Started by Muut Archive 11 years ago · 2 replies · 1271 views
11 years ago

Hi, I have been looking into documentation and it seems a bit confusing, especially part with assets.add vs assets.addJS, and additional options (which do not work for me).

How can I load some script in the header (like the ones for older browsers) and other in the footer. I do not pipe scripts (npm scripts to build so I concatenate it myself).

11 years ago

Check for example Antimatter's templates/partials/base.html.twig. It defines a bottom block for js by calling {{ assets.js('bottom') }}

You can add assets in that block for example by calling

{% do assets.addJs('theme://js/slidebars.min.js', {group: 'bottom'}) %}

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 2578 9 years ago
Archive · by Muut Archive, 9 years ago
2 1698 9 years ago
Archive · by Muut Archive, 9 years ago
2 4990 9 years ago
Archive · by Muut Archive, 9 years ago
1 3818 9 years ago
Archive · by Muut Archive, 9 years ago
3 1805 9 years ago