0

I'm trying to use GLide.js and after installing it with npm, i'm trying to access it using script src

This is the code i'm using

<script src="<?php  echo ABSPATH.'/node_modules/@glidejs/glide/dist/glide.min.js';?>"></script>

I know wordpress has specific methods to acess folder for example:

<script src="<?php bloginfo('template_url'); ?>/js/navbar.js"></script>

but since node modules is in root , i'm guessing there's another one

Thanks in advance!

  • ABSPATH is a directory path not an URL, use site_url() or home_url() instead. – majick Oct 14 at 11:02
  • nevermind , slow loading, you fixed it thanks ! – Pedro Ferreira Oct 14 at 11:15
  • missing an echo, and you can put the path as the first argument if you want to: eg. <script src="<?php echo site_url('/node_modules/@glidejs/glide/dist/glide.min.js'); ?>"></script> – majick Oct 14 at 11:15
  • You should use the enqueue script system rather than hardcoding the script tags – Tom J Nowell Oct 14 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.