Join the Webstudio community

Updated 4 months ago

Particle Javascript (Resolved)

At a glance

The community member is trying to add a JavaScript code from Codepen to their HTML, but is having trouble getting it to work. They have tried embedding the CSS and JS code, adding an ID, and checking if Client Only is turned off, but nothing is showing up except a red background.

The comments suggest that the community member needs to include the particles.js library and provide the link to their build for others to help. After some back-and-forth, another community member provides the solution: the community member should add the CSS and JavaScript code directly in the HTML Embed, without needing to add any IDs or classes. The solution is marked as resolved.

Useful resources
How to add this Javascript Code? https://codepen.io/VincentGarreau/pen/bGxvQd
I tried to embedd the CSS wrapped in <style></style> and the JS wrapped in <script></script> into HTML Embed Code. Then added this ID to a box: particles-js, but nothing is shown except the red background. I also checked if Client Only is turned off.
C
O
M
31 comments
How to add Javascript?
You need to share the link to your build for anyone to look into it
what is particlesJS?
I don't see any library you added
in codepen this library is added
Thanks for helping. I tried to add this to my Code, but it didn't work:

<script src="https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js">
</script>

<script src="https://threejs.org/examples/js/libs/stats.min.js">
</script>

or the two within <script></script>

src="https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js"

src="https://threejs.org/examples/js/libs/stats.min.js"
have you tried asking gpt?
yep I just tried that and also tried different orders of putting the code, but nothing seems to work. I must be missing something noobish >.<

<style>"CSS-Code"</style>

<script src="https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js"></script>
<script src="https://threejs.org/examples/js/libs/stats.min.js"></script>

"HTML-Code"

<script>"JS-Code"</script>
So you don't need to add threeJS
here is the code you have to add in an HTML Embed :
<style> .particles-js-canvas-el { background-color: red; position: absolute; width: 100%; height: 100%; left: 0%; right: 0%; bottom: 0%; top: 0%; z-index: 0; } </style> <script src="https://cdn.jsdelivr.net/npm/[email protected]/particles.min.js"></script>
The difficulty is the following: the div id the generating a canvas with is own CSS Class so you have to target it to make it absolute
And CSS variables works really fine! You can use it!
Thanks a lot for helping me. I put your code within HTML Embed and tried to get what you mean with the Console and id. But it's not working yet
Attachments
screen-2.png
screen.png
no need to add the ID And the class
Just add :

<style>
.particles-js-canvas-el {
background-color: red;
position: absolute;
width: 100%;
height: 100%;
left: 0%;
right: 0%;
bottom: 0%;
top: 0%;
z-index: 0;
}
</style>
in an HTML Code with npm and the particules
thanks I finally made it with your help πŸ™‚
Very cool help. Wish this Webstudio was more popular, but I guess being Open Source there's no budget for marketing. I'll definitely recommend it to my designer friends/colleagues. Here's the source website of the creator for easy and intuitive control of those particle effects: https://vincentgarreau.com/particles.js/
How to add Javascript? (Resolved)
Particle Javascript (Resolved)
Add a reply
Sign up and join the conversation on Discord
into HTML Embed Code. Then added this ID to a box: particles-js, but nothing is shown except the red background. I also checked if Client Only is turned off.","url":"https://help.webstudio.is/particle-javascript-resolved-f4LvxyJjpH9M","identifier":"f4LvxyJjpH9M","publisher":{"@type":"Organization","name":"Webstudio","logo":{"@type":"ImageObject","url":"https://assets.usehall.com/org_01JEYTC8WWMF7N46W9J4J7CFDP/c7f10f06-f934-4e35-b008-431a89254f9f.png"}},"comment":[{"@type":"Comment","text":"How to add Javascript?","dateCreated":"2024-10-14T16:48:09.872Z","dateModified":"2024-10-14T16:48:09.872Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/1713acb2-b036-41d1-84e2-eca1238dc321","name":"Candle","identifier":"1713acb2-b036-41d1-84e2-eca1238dc321","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"commentCount":0,"comment":[],"position":1,"upvoteCount":0},{"@type":"Comment","text":"You need to share the link to your build for anyone to look into it","dateCreated":"2024-10-14T17:15:37.155Z","dateModified":"2024-10-14T17:15:37.155Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/cdd3ed87-53a0-414a-885a-56b7939e412a","name":"Oleg Isonen","identifier":"cdd3ed87-53a0-414a-885a-56b7939e412a","image":"https://cdn.discordapp.com/avatars/469405813048606720/8b66a5882214c63ee6148fcce3ef8e93.webp?size=256"},"commentCount":0,"comment":[],"position":2,"upvoteCount":0},{"@type":"Comment","text":"Here is the link: https://p-73071613-a5ef-4302-86a2-b870752f952d.apps.webstudio.is/?authToken=71d5bf8c-f5b8-4855-93c0-5abc6f2d97f3&mode=preview","dateCreated":"2024-10-14T17:24:07.421Z","dateModified":"2024-10-14T17:24:07.421Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/1713acb2-b036-41d1-84e2-eca1238dc321","name":"Candle","identifier":"1713acb2-b036-41d1-84e2-eca1238dc321","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"commentCount":0,"comment":[],"position":3,"upvoteCount":0},{"@type":"Comment","text":"what is particlesJS?","dateCreated":"2024-10-14T17:26:52.690Z","dateModified":"2024-10-14T17:26:52.690Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/cdd3ed87-53a0-414a-885a-56b7939e412a","name":"Oleg Isonen","identifier":"cdd3ed87-53a0-414a-885a-56b7939e412a","image":"https://cdn.discordapp.com/avatars/469405813048606720/8b66a5882214c63ee6148fcce3ef8e93.webp?size=256"},"commentCount":0,"comment":[],"position":4,"upvoteCount":0},{"@type":"Comment","text":"I don't see any library you added","dateCreated":"2024-10-14T17:26:58.672Z","dateModified":"2024-10-14T17:26:58.672Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/cdd3ed87-53a0-414a-885a-56b7939e412a","name":"Oleg Isonen","identifier":"cdd3ed87-53a0-414a-885a-56b7939e412a","image":"https://cdn.discordapp.com/avatars/469405813048606720/8b66a5882214c63ee6148fcce3ef8e93.webp?size=256"},"commentCount":0,"comment":[],"position":5,"upvoteCount":0},{"@type":"Comment","text":"","dateCreated":"2024-10-14T17:27:24.884Z","dateModified":"2024-10-14T17:27:24.884Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/cdd3ed87-53a0-414a-885a-56b7939e412a","name":"Oleg Isonen","identifier":"cdd3ed87-53a0-414a-885a-56b7939e412a","image":"https://cdn.discordapp.com/avatars/469405813048606720/8b66a5882214c63ee6148fcce3ef8e93.webp?size=256"},"commentCount":0,"comment":[],"position":6,"upvoteCount":0},{"@type":"Comment","text":"in codepen this library is added","dateCreated":"2024-10-14T17:27:37.990Z","dateModified":"2024-10-14T17:27:37.990Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/cdd3ed87-53a0-414a-885a-56b7939e412a","name":"Oleg Isonen","identifier":"cdd3ed87-53a0-414a-885a-56b7939e412a","image":"https://cdn.discordapp.com/avatars/469405813048606720/8b66a5882214c63ee6148fcce3ef8e93.webp?size=256"},"commentCount":0,"comment":[],"position":7,"upvoteCount":0},{"@type":"Comment","text":"Thanks for helping. I tried to add this to my Code, but it didn't work:or the two within src=\"https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js\"src=\"https://threejs.org/examples/js/libs/stats.min.js\"","dateCreated":"2024-10-14T17:35:44.812Z","dateModified":"2024-10-14T17:35:44.812Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/1713acb2-b036-41d1-84e2-eca1238dc321","name":"Candle","identifier":"1713acb2-b036-41d1-84e2-eca1238dc321","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"commentCount":0,"comment":[],"position":8,"upvoteCount":0},{"@type":"Comment","text":"have you tried asking gpt?","dateCreated":"2024-10-14T17:52:44.810Z","dateModified":"2024-10-14T17:52:44.810Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/cdd3ed87-53a0-414a-885a-56b7939e412a","name":"Oleg Isonen","identifier":"cdd3ed87-53a0-414a-885a-56b7939e412a","image":"https://cdn.discordapp.com/avatars/469405813048606720/8b66a5882214c63ee6148fcce3ef8e93.webp?size=256"},"commentCount":0,"comment":[],"position":9,"upvoteCount":0},{"@type":"Comment","text":"yep I just tried that and also tried different orders of putting the code, but nothing seems to work. I must be missing something noobish >.<\"HTML-Code\"","dateCreated":"2024-10-14T18:53:01.802Z","dateModified":"2024-10-14T18:53:01.802Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/1713acb2-b036-41d1-84e2-eca1238dc321","name":"Candle","identifier":"1713acb2-b036-41d1-84e2-eca1238dc321","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"commentCount":0,"comment":[],"position":10,"upvoteCount":0},{"@type":"Comment","text":"All right @Candle I did it: https://apple-dock-animation-d011k.wstd.io/particles-js","dateCreated":"2024-10-14T19:53:26.479Z","dateModified":"2024-10-14T19:53:26.479Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":11,"upvoteCount":0},{"@type":"Comment","text":"Really like this library","dateCreated":"2024-10-14T19:53:36.976Z","dateModified":"2024-10-14T19:53:36.976Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":12,"upvoteCount":0},{"@type":"Comment","text":"So you don't need to add threeJS","dateCreated":"2024-10-14T19:54:04.204Z","dateModified":"2024-10-14T19:54:04.204Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":13,"upvoteCount":0},{"@type":"Comment","text":"here is the code you have to add in an HTML Embed :","dateCreated":"2024-10-14T19:55:51.969Z","dateModified":"2024-10-14T19:55:51.969Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":14,"upvoteCount":0},{"@type":"Comment","text":" ","dateCreated":"2024-10-14T19:56:31.585Z","dateModified":"2024-10-14T19:56:31.585Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":15,"upvoteCount":0},{"@type":"Comment","text":"And add the particles-js","dateCreated":"2024-10-14T19:57:17.572Z","dateModified":"2024-10-14T19:57:17.572Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":16,"upvoteCount":0},{"@type":"Comment","text":"all in HTML Embed","dateCreated":"2024-10-14T19:57:35.646Z","dateModified":"2024-10-14T19:57:35.646Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":17,"upvoteCount":0},{"@type":"Comment","text":"The difficulty is the following: the div id the generating a canvas with is own CSS Class so you have to target it to make it absolute","dateCreated":"2024-10-14T19:58:24.307Z","dateModified":"2024-10-14T19:58:24.307Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":18,"upvoteCount":0},{"@type":"Comment","text":"(check in the console)","dateCreated":"2024-10-14T19:58:30.239Z","dateModified":"2024-10-14T19:58:30.239Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":19,"upvoteCount":0},{"@type":"Comment","text":"hope it will help you!","dateCreated":"2024-10-14T19:58:37.251Z","dateModified":"2024-10-14T19:58:37.251Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":20,"upvoteCount":0},{"@type":"Comment","text":"And CSS variables works really fine! You can use it!","dateCreated":"2024-10-14T20:07:46.756Z","dateModified":"2024-10-14T20:07:46.756Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":21,"upvoteCount":0},{"@type":"Comment","text":"Thanks a lot for helping me. I put your code within HTML Embed and tried to get what you mean with the Console and id. But it's not working yet","dateCreated":"2024-10-14T20:33:17.457Z","dateModified":"2024-10-14T20:33:17.457Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/1713acb2-b036-41d1-84e2-eca1238dc321","name":"Candle","identifier":"1713acb2-b036-41d1-84e2-eca1238dc321","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"commentCount":0,"comment":[],"position":22,"upvoteCount":0},{"@type":"Comment","text":"no need to add the ID And the class","dateCreated":"2024-10-14T20:37:30.509Z","dateModified":"2024-10-14T20:37:30.509Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":23,"upvoteCount":0},{"@type":"Comment","text":"Just add :","dateCreated":"2024-10-14T20:37:46.316Z","dateModified":"2024-10-14T20:37:46.316Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":24,"upvoteCount":0},{"@type":"Comment","text":"in an HTML Code with npm and the particules","dateCreated":"2024-10-14T20:38:02.450Z","dateModified":"2024-10-14T20:38:02.450Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":25,"upvoteCount":0},{"@type":"Comment","text":"https://tenor.com/view/kiss-gif-13519436822523084554","dateCreated":"2024-10-14T20:43:13.845Z","dateModified":"2024-10-14T20:43:13.845Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/1713acb2-b036-41d1-84e2-eca1238dc321","name":"Candle","identifier":"1713acb2-b036-41d1-84e2-eca1238dc321","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"commentCount":0,"comment":[],"position":26,"upvoteCount":0},{"@type":"Comment","text":"thanks I finally made it with your help πŸ™‚","dateCreated":"2024-10-14T20:43:45.845Z","dateModified":"2024-10-14T20:43:45.845Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/1713acb2-b036-41d1-84e2-eca1238dc321","name":"Candle","identifier":"1713acb2-b036-41d1-84e2-eca1238dc321","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"commentCount":0,"comment":[],"position":27,"upvoteCount":0},{"@type":"Comment","text":"yeaaaah! Congrats!!!","dateCreated":"2024-10-14T20:43:47.521Z","dateModified":"2024-10-14T20:43:47.521Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/a5bb43e0-c553-447b-82cc-c4c4177bf6b9","name":"Milan Boisgard | Uncode School","identifier":"a5bb43e0-c553-447b-82cc-c4c4177bf6b9","image":"https://cdn.discordapp.com/avatars/378836225009647628/67e9e7df4880d828a727cc3efba93c81.webp?size=256"},"commentCount":0,"comment":[],"position":28,"upvoteCount":0},{"@type":"Comment","text":"Very cool help. Wish this Webstudio was more popular, but I guess being Open Source there's no budget for marketing. I'll definitely recommend it to my designer friends/colleagues. Here's the source website of the creator for easy and intuitive control of those particle effects: https://vincentgarreau.com/particles.js/","dateCreated":"2024-10-14T20:56:42.334Z","dateModified":"2024-10-14T20:56:42.334Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/1713acb2-b036-41d1-84e2-eca1238dc321","name":"Candle","identifier":"1713acb2-b036-41d1-84e2-eca1238dc321","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"commentCount":0,"comment":[],"position":29,"upvoteCount":0},{"@type":"Comment","text":"How to add Javascript? (Resolved)","dateCreated":"2024-10-14T20:57:28.018Z","dateModified":"2024-10-14T20:57:28.018Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/1713acb2-b036-41d1-84e2-eca1238dc321","name":"Candle","identifier":"1713acb2-b036-41d1-84e2-eca1238dc321","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"commentCount":0,"comment":[],"position":30,"upvoteCount":0},{"@type":"Comment","text":"Particle Javascript (Resolved)","dateCreated":"2024-10-14T21:26:02.915Z","dateModified":"2024-10-14T21:26:02.915Z","author":{"@type":"Person","url":"https://help.webstudio.is/members/1713acb2-b036-41d1-84e2-eca1238dc321","name":"Candle","identifier":"1713acb2-b036-41d1-84e2-eca1238dc321","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"commentCount":0,"comment":[],"position":31,"upvoteCount":0}],"author":{"@type":"Person","url":"https://help.webstudio.is/members/1713acb2-b036-41d1-84e2-eca1238dc321","name":"Candle","identifier":"1713acb2-b036-41d1-84e2-eca1238dc321","image":"https://cdn.discordapp.com/embed/avatars/3.png"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0}}]