• Matt Keys

    (@mattkeys)


    Hello,

    We are continuing to hunt down performance issues on our site and have discovered that this plugin is loading the jQuery library site wide. Regardless of wether or not the plugin is being used to display a calculator on the page or not.

    The offending code can be found here: wp-content/plugins/cost-calculator-builder/includes/classes/CCBFrontController.php#13

    add_action(
    'wp_enqueue_scripts',
    function () {
    wp_enqueue_script( 'jquery' );
    }
    );

    This code indiscriminately loads jQuery. Instead the proper way to load jQuery would be as a dependency in calls to wp_enqueue_script. Example:

    wp_enqueue_script( 'calc-builder-main-js', CALC_URL . '/frontend/dist/bundle.js', array( 'jquery', 'cbb-sticky-sidebar-js' ), CALC_VERSION, true );

    In this way, jQuery will only load when the calc-builder-main-js script loads. So it will only load on pages that need it.

  • You must be logged in to reply to this topic.