VincentGarreau / particles.js

A lightweight JavaScript library for creating particles
https://vincentgarreau.com/particles.js/
MIT License
28.72k stars 4.81k forks source link

Docs Usage example doesn't work with npm Install. #477

Open ZackPlauche opened 2 years ago

ZackPlauche commented 2 years ago

The usage docs don't make any sense on how to use this with node.

Do you have to import the CSS as well? How do you import it from node_modules?

And why is this part not discussed in the docs?

DanielOberlechner commented 2 years ago

Hi, it's not discussed because there isn't any... Have a look: https://cdnjs.com/libraries/particles.js

You'll see there is only a js to implement. Compile the _nodemodules/particles.js/particles.js and implement it on your site. Then set a dom id to: "particles.js". In my case it was body:

Then you probably don't want the default behaviour of this library so you go here: https://vincentgarreau.com/particles.js/ Play around with the styles until you're happy and download the particles.json. Now make on your webserver the particles.json possible to get loaded. In my case it is django and I did put it in the static directory so it can be loaded. Next simply use the following JavaScript at the end of your site: ` document.addEventListener("DOMContentLoaded", function() { particlesJS.load('particles-js', 'particles.json'); }); ` Now you are done. If you have any trouble feel free to contact me here, I'll try my best to help you. :) Kind regards, Daniel Oberlechner