How to Use Particlesjs Library

Particlesjs is an amazing JavaScript library that will let you make particles backgrounds. There are different library for creating particle, but Particlesjs is at the top and easy to use. This article will teach you step by step on how to use particlesjs library. You will enjoy learning and using this amazing library. Before diving into code and learning it, let’s see and example.

Particlesjs best example

See the Pen Practicing particlesjs by Hujjat Nazari (@Hujjat) on CodePen.dark

You probably have seen such an example or any website using this kind of background. So now let’s learn how to use particlesjs library.

How to Use Particlesjs Library?

To use particlesjs, first you have to create it. You can go to particlesjs site and start creating your own particle. It has an visual option panel that will let you customize it the way you want. You must take a few hours practicing and mastering the options. Change every option possible to understand how it works and how it changes.

how to use parrticlesjs library site
how to use parrticlesjs library site

We will customize is a little and than use it as an example. After you learned how to use it in real project. you can add you own particle example. After customizing, click on the right top Codepen button. It will open your project in a new pen. After that you can customize and give it a name if you want.

Here is how we customized:

See the Pen particles.js practice by Hujjat Nazari (@Hujjat) on CodePen.dark

Now let’s add it in our local project.

You need to create three files; one for HTML, one for JavaScript and one for CSS. After creating those files, make sure you link the JavaScript and CSS to HTML page.

In your HTML file, all you need is to have a tag with an id of particles-js( you can name it anything you want).

In your CSS file, just write the partilce background code

For JavaScript section, first you need to add the partilclesjs library file. You can use cdn as well. Here is the cdn for that

After adding particlesjs file, you can write the code generated on codepen in JavaScript section. You don’t need to add all the code, just the particle function with all it’s property.

It will look like this: ( sure your code is similar to this ).

Now you are good to go. Just open your project in browser and it will work perfectly. It was this easy to use particlesjs library.


We hope it has been informative for you. If you have any question related this topic or you face any problem on how to use particlesjs library, feel free to comment it bellow. 🙂

You might also like

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.