Site logo

Archived topic

slick Slider - where to place js in GP Hooks?

3 replies · Started by Ema on January 29, 2022

Viewing posts 1–4 of 4

Hello, I'm wondering where the best place is to place Slick Slider's CDN

CSS in the head hook. But does JS go into the body or footer?

CSS

<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.css"/>

JS

<script type="text/javascript" src="//cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js"></script>

Thanks in advance

Ema

Hi there,

it depends on how the Javascript is written as the code within the script may need to execute after some HTML is rendered on the page. Other scripts however do not.

I would put in the wp_footer hook as it will run after the page has loaded and not interfere as much with the sites performance. If it works as expected then leave as is.

If theres an issue eg. a Slider is badly displayed on initial load, then move it to the wp_head hook.

Thank you, David, Perfect. I'm playing with Swiper Slider now.

Awesome - glad to be of help!

This archived topic is closed to new replies.