Avada Forums Community Forum Unnecessary JS Files Load Even When Fusion Elements Disabled Reply To: Unnecessary JS Files Load Even When Fusion Elements Disabled

Michael C
Keymaster
Post count: 528

Hi @nlabrake,

This is already implemented in the builder. If you have an element disabled then the element specific JS will not be enqueued because the element class will not be loaded (which contains function add_scripts). However, not all JS files are specific to just one element – some are also shared with Avada. So for any like that the JS files still have to be enqueued even if the element is disabled.

For example, if you disable the Flip Box element then fusion-flip-boxes.js will not be enqueued. However, if you disable the blog element fusion-blog.js still will. That is because the core Avada theme also utilizes that same JS file and is required for the archive layouts.

Also please note, if you don’t want a script enqueued you do not need to add a filter, you can use the methods in the class. For example:

Fusion_Dynamic_JS::deregister_script( 'bootstrap-modal' );