Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

How to properly load js files in the footer?

Started by Muut Archive 11 years ago · 2 replies · 919 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 1352 9 years ago
Archive · by Muut Archive, 9 years ago
2 935 9 years ago
Archive · by Muut Archive, 9 years ago
2 4063 9 years ago
Archive · by Muut Archive, 9 years ago
1 2949 9 years ago
Archive · by Muut Archive, 9 years ago
3 1119 9 years ago