I am trying to use a JavaScript library (from GitHub) on my website but I can’t get it to work. It works when I set it up in VS code but not when I upload my code to cpanel (along with the required files). The website is a wordpress site so I just create page templates and link the templates to the specific pages. I have uploaded all of the code and files correctly and this is how I have tried to include them:
#particles-js{ position: relative; z-index: 1; background-color: #000; min-height: 100vh; min-width: 100vw; }
<div id="particles-js"></div> <script src="/home/fittecha/repositories/particles.js/particles.js"></script> <script src="/home/fittecha/repositories/particles.js/particles.min.js"></script> <script src="/home/fittecha/repositories/particles.js/demo/js/app.js"></script>
I also tried using <?php include '/home/fittecha/repositories/particles.js/demo/js/app.js'; ?>
etc, but that didn’t work either. Please advise.
Advertisement
Answer
I managed to sort it out. I changed the html to a php include function and placed it at the bottom of my document:
<script> <?php include '/home/fittecha/repositories/particles.js/particles.js'; include '/home/fittecha/repositories/particles.js/particles.min.js'; include '/home/fittecha/repositories/particles.js/demo/js/app.js'; ?> </script>
I am not sure why this didn’t work before when I tried it but it’s all working now