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!

4
  • ABSPATH is a directory path not an URL, use site_url() or home_url() instead.
    – majick
    Commented Oct 14, 2019 at 11:02
  • nevermind , slow loading, you fixed it thanks ! Commented Oct 14, 2019 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
    Commented Oct 14, 2019 at 11:15
  • You should use the enqueue script system rather than hardcoding the script tags
    – Tom J Nowell
    Commented Oct 14, 2019 at 12:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.