• I would like to propose deferring the loading of the compset.js to the footer if that’s possible?

    wp_enqueue_script(‘dfrcs_compsets’, DFRCS_URL . ‘js/compsets.js’, array(‘jquery’), DFRCS_VERSION, true);

    It’s single line change in actions.php, this would help with performance and is a best practice for loading javascript.

    If moving to the footer is not possible, perhaps deferring the javascript instead?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter agile_pixel

    (@agile_pixel)

    Or if it’s not for everyone having it as an option in the CMS

    Plugin Author datafeedr

    (@datafeedrcom)

    Hi

    You can add the following code to a custom plugin to load the compsets.js file either in the footer or use defer (or both… it’s up to you).

    add_action( 'wp_enqueue_scripts', 'modify_dfrcs_compsets_script', 10000000 ); // Priority must be higher than the original enqueue function.

    function modify_dfrcs_compsets_script() {

    // Dequeue the original script
    wp_dequeue_script( 'dfrcs_compsets' );

    // Re-enqueue the script in the footer
    wp_enqueue_script(
    'dfrcs_compsets',
    DFRCS_URL . 'js/compsets.js',
    array( 'jquery' ),
    DFRCS_VERSION,
    true // Set to true to load in the footer
    );
    }

    Here’s how to add a custom plugin to your site: https://datafeedrapi.helpscoutdocs.com/article/32-creating-your-own-custom-plugin

    Hope this helps!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.