Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

282
Views
VantaJS background effect will not destroy. Why?

Description

My web page project has a VantaJS dynamic background, and I'm trying to add an checkbox option to disable the dynamic background.

The "Cleanup" section of the official VantaJS docs explains how to destroy a Vanta effect: https://github.com/tengbao/vanta#cleanup

const effect = VANTA.WAVES('#my-background')
effect.destroy() // e.g. call this in React's componentWillUnmount

Problem

Here's my example code, where I've added a Bootstrap checkbox that should be (in my understanding) destroying the Vanta effect when toggled: https://jsfiddle.net/playdohsniffer/un6hx1q5/131/

Why isn't the Vanta effect being killed when the checkbox is toggled?

It seems like it should work using vanilla Javascript. Is it required to use React to invoke said destroy() function? I'm not familiar with React framework at all...

More details

I'm aware that there's several ways you can hide/remove specific elements from the DOM using vanilla JavaScript. In my example code, I've added two additional buttons demonstrating two such methods:

  • style visibility property
  • HTML DOM remove() method

However, these various methods are not desirable since they hide/remove the entire contents within the div. Instead, I need to figure out how to destroy the VantaJS element being rendered in the div background (cleaning up consumed resources is the proper way anyway..)

Any advise is appreciated.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!