Install js js in wordpress or use another method

How to implement or install particles.js in wordpress?

http://vincentgarreau.com/particles.js/

I tried installing particle.js but it does not work, maybe I missed some important details.

I also tried the "login page" plugin and then try to copy it to the content page, but still no luck.

Any suggestion would be a big help

Thanks.

+6
javascript wordpress
source share
2 answers

There are several ways to do the same. I describe how you should do this in a standard way. Download particle.js to your active theme folder (I downloaded it to the "js" folder in the theme directory. Open the functions.php function in the active theme and paste the following code.

 function load_my_scripts(){ wp_enqueue_script('muaw-ajax', get_template_directory_uri().'/js/particles.js'); } add_action('wp_enqueue_scripts', 'load_my_scripts'); 

Save the changes made to functions.php, then it should be included in your theme.

0
source share

You can queue a trusted CDN if you do not have the option to install it locally.

The following should be added to your functions.php if you have a standard WordPress architecture.

 function enqueue_particlejs(){ wp_enqueue_script('particle-js','https://cdn.jsdelivr.net/npm/ particles.js@2.0.0 /particles.min.js'); } add_action('wp_enqueue_scripts', 'enqueue_particlejs'); 

Then you will need to use their way of actually launching on the page, which means assigning a particle-js identifier to one of your dom elements.

 <div id="particle-js"></div> 

If you don't have access to javascript files, you can get away with this:

 <script> particlesJS.load('particle-js', '<?= get_template_directory_uri() . '/assets/particlejs.json' ?>', function() { }); </script> 

You will need to create the filejs.json file somewhere in your WordPress directory and link to it above.

They give one example or simply export it from the site you are linking to.

0
source share

All Articles