Dark Raw

jQuery

Use jQuery links in the header only when you need them!

To load the jQuery library from i.e. https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js takes DNS lookup time and loading time, reducing the page load speed. Wordpress often puts the jQuery CDN on every single page. With Hugo you can set it in a way only to show on pages where jQuery is required.

It’s very easy. On your *.md add this command to the front matters:

jquery: true

This code will go in your baseof.html:

{{ with .Params.jquery }} {{/* checks if the parameter exists */}}
OR 
{{ if eq .Params.jquery true }} {{/* checks if the boolean value of the parameter is set to true */}}
<--- jQuery script --->
{{ end }}

© 2022 - Bake the Gloom away!