Removing unnecessary JavaScript from Beaver Builder cache

At my company, we’re using the Beaver Builder plugin to give more flexibility to our marketing team, and it has been amazing so far, but it has come to a performance cost.

Most of our codebase is being built with Webpack and added to the page. We are exporting jQuery globally and we got rid of the default jQuery, in other to have only one jQuery on the page.
Lately, we’ve been working on improving our codebase and getting rid of jQuery as much as possible, and using more Vanilla JavaScript, we don’t have any Beaver Builder module that is using jQuery, and everything is fine now we’re focusing on removing jQuery completely.

When we create a new blank page and check the output of the cache there is some code there (FLBuilderLayout , etc) that needs jQuery in order to work, be can get rid of the Javascript file completely but we want to be able to add simple Vanilla Javascript snippets if necessary from the Beaver Builder layout.

So my question is: How can we remove those unnecessary functions (_isMobile(), _destroy(), _initParallaxBackground()) from the Javascript output? Also if we remove that, will it affect the creation of new modules (without jQuery)?

Keep in mind that we only need this only when Beaver Builder is inactive (!isset($_GET['fl_builder'])).

Any help would be appreciated!

1 Like