Improved loading speed of pages that include reCaptcha in WordPress

A system that allows you to avoid traffic from automated programs or bots is Google’s reCaptcha project. This project has evolved from version v1 to v3, and with this latest version, also called invisible reCaptcha, which appeared in 2018, it is allowed that human users do not need to perform any action to verify that they are not bots, not even marking images of google street (v1) or a box of ‘I’m not a robot’ (v2).

To do this, it introduces a risk analysis and creates different risk profiles, which helps web administrators to verify that the IP that wants to identify itself in a system is a real person and not a malicious program.

This new version of reCAPTHA does not require anything from the user, it will run in the background, automatically classifying and identifying users between robots or humans, using a scoring system based on the patterns of their activity, creating different risk profiles.

But the use of this plugin in WordPress causes the loading speed of our page to be decreased, affecting the PageSpeed ​​score.

For example, a page that has a Google PageSpeed ​​Insights value of 93, goes to 50 when integrating the reCaptcha (a loss of 43 points), due to the additional code load for its execution.

To avoid this decrease in the loading speed of the web, we can defer the loading of this plugin until the moment the user interacts with the web. This deferral must be in accordance with what the user does when the web page is loaded. Thus, for example, if we defer until a scroll is made and the form where the access control must be carried out initially appears on our website, without the need to scroll, and the user interacts with it, the reCaptcha plugin will not allow the submitting the form for not having loaded its code in the user’s browser.

In order to avoid this problem, we can defer the loading of reCaptcha, but reloading it on any user interaction, for example, moving the mouse.

There are different plugins on the market that allow you to defer the loading of any JavaScript code, but if these cannot perform the specific functions required, you can turn to a web developer who analyzes the specific case of pages with loading speed problems and develops the plugin. specific code that improves its positioning.

For our part, at Doowebs we have the following plugin that, installed in WordPress, offers us a solution to this problem, notably improving the speed of the web in which Google recaptcha has been included in the forms of the Contact Form 7 plugin.

You can download and install it on WordPress for free.