Skip Navigation

[Resolved] I need to defer loading the recaptcha script for optimization purposes

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 7.57 hours from now. Thank you for your understanding.

This topic contains 1 reply, has 2 voices.

Last updated by Jamal 1 month, 1 week ago.

Assigned support staff: Jamal.


My Page Speed Insights are failing due to "unused javascript". The file in question is being loaded by After searching the file structure of my wordpress site, it seems that it's coming from the Types plugin. I can't figure out how to disable this to improve my page speed. I'd be willing to use a different recaptcha plugin that's not built into Types that will give me more control over which pages it's loaded on as right now it's loaded globally, even on non "contact us" pages.



Languages: English (English ) French (Fran├žais )

Timezone: Africa/Casablanca (GMT+01:00)

Hello and thank you for contacting the Toolset support.

Currently, there is no built-in way in WordPress or Toolset to achieve this. You will need to use custom code to change how the script is being added. For example, the following code will add the "defer" attribute to the script tag:

add_filter( 'clean_url', function( $url )
    if ( FALSE === strpos( $url, '' ) )
    { // not our file
        return $url;
    // Must be a ', not "!
    return "$url' defer='defer";
}, 11, 1 );

You can explore different techniques in this StackOverflow thread

You may also want to use a 3rd Party plugin such as "Async JavaScript"

Note that our script handler is called "wpt-cred-recaptcha". Check this screenshot hidden link

I hope this helps. Let me know if you have any questions.