how to load confetti only one time for a user

I want to load the confetti at a specific time. After that time is passed or once the confetti is loaded for a user, I don’t want it to be seen again for that user when he refreshes the page or changes the page.

I used this code to run the confetty

<script src="https://www.wpromotions.eu/confetti.min.js"></script>
<script>confetti.start()</script>
<script>setTimeout(function(){confetti.stop();},6000)</script> 

Answer

Consider using the Local Storage API. You can save values like this:

let firstTime = localStorage.getItem("confetti_loaded");

if (firstTime != 'yes') {
   // first time loaded!
   localStorage.setItem("confetti_loaded","yes");
   confetti.start()
}

Now this will load your confetti.min.js only 1 time then after no matter how many times user refresh the page if you wants to load js again simply remove the value that is store in local storage.

localStorage.setItem("confetti_loaded","");