Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught ReferenceError: Stats is not defined in Wordpress #514

Open
mital-tyche opened this issue Apr 27, 2023 · 1 comment
Open

Uncaught ReferenceError: Stats is not defined in Wordpress #514

mital-tyche opened this issue Apr 27, 2023 · 1 comment

Comments

@mital-tyche
Copy link

<style> .particles-js-canvas-el { width: 100%; height: 100%; position: absolute; z-index: -1; top: 0; left: 0; } </style> <script src="https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js"></script> <script> particlesJS("particles-js", { "particles": { "number": { "value": 380, "density": { "enable": true, "value_area": 800 } }, "color": { "value": "#ffffff" }, "shape": { "type": "circle", "stroke": { "width": 0, "color": "#000000" }, "polygon": { "nb_sides": 5 }, "image": { "src": "img/github.svg", "width": 100, "height": 100 } }, "opacity": { "value": 0.5, "random": false, "anim": { "enable": false, "speed": 1, "opacity_min": 0.1, "sync": false } }, "size": { "value": 3, "random": true, "anim": { "enable": false, "speed": 40, "size_min": 0.1, "sync": false } }, "line_linked": { "enable": true, "distance": 150, "color": "#ffffff", "opacity": 0.4, "width": 1 }, "move": { "enable": true, "speed": 6, "direction": "none", "random": false, "straight": false, "out_mode": "out", "bounce": false, "attract": { "enable": false, "rotateX": 600, "rotateY": 1200 } } }, "interactivity": { "detect_on": "canvas", "events": { "onhover": { "enable": true, "mode": "grab" }, "onclick": { "enable": true, "mode": "push" }, "resize": true }, "modes": { "grab": { "distance": 140, "line_linked": { "opacity": 1 } }, "bubble": { "distance": 400, "size": 40, "duration": 2, "opacity": 8, "speed": 3 }, "repulse": { "distance": 200, "duration": 0.4 }, "push": { "particles_nb": 4 }, "remove": { "particles_nb": 2 } } }, "retina_detect": true }); /* ---- stats.js config ---- */ var count_particles, stats, update; stats = new Stats; stats.setMode(0); stats.domElement.style.position = 'absolute'; stats.domElement.style.left = '0px'; stats.domElement.style.top = '0px'; document.body.appendChild(stats.domElement); count_particles = document.querySelector('.js-count-particles'); update = function() { stats.begin(); stats.end(); if (window.pJSDom[0].pJS.particles && window.pJSDom[0].pJS.particles.array) { count_particles.innerText = window.pJSDom[0].pJS.particles.array.length; } requestAnimationFrame(update); }; requestAnimationFrame(update); </script>

I added same code in my elementor but it's not working can you check that bcz every time it cause error..
https://prnt.sc/S0aW-Qulg7_M

@uly081219
Copy link

When using Elementor, it is possible to run into problems due to conflicts with other scripts or limitations in the Elementor environment.

To fix the issue, you can follow these steps:

Make sure you have Elementor Pro installed as it may be required for some advanced features.

Check if you have included the required JavaScript and CSS files for Particle.js. You can do this by going to your WordPress dashboard, going to Elementor > Customizer and checking the Custom CSS and Custom JavaScript sections. Make sure the required Particle.js files are properly linked.

Make sure the Particle.js library is loaded before your custom script. If you're adding code using Elementor's custom code feature, try moving the script tag with the Particle.js library above your custom script.

Double check for errors in the console log. In a browser, right-click on a web page and select Inspect or Inspect Element to open Developer Tools. Look for any error messages in the console tab. If there are errors related to the Particle.js library or your custom script, this may indicate a problem that needs to be fixed.

Consider using a different approach. If the above steps don't resolve the issue, you may need to use an alternative method to integrate Particle.js with Elementor. One option is to create your own Elementor widget using the Particle.js library, or find a compatible Particle.js plugin available in the WordPress repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants