Recaptcha: Recaptcha v2 js loads multiple times

Created on 17 Oct 2019  路  6Comments  路  Source: google/recaptcha

Issue description

recaptcha__en.js loads multiple times on any page using recaptcha v2. This is a small issue when trying to optimize page speed, as with all the reloads it comes to 270KB.

Environment

Tested on multiple production, staging, and locally hosted servers using wordpress.

  • PHP version: 7, 5.6
  • Web server name and version: local, various websites.
  • google/recaptcha version: V2
  • Browser name and version: chrome 77.0.3865.90

Reproducing the issue

https://patrickhlauke.github.io/recaptcha/

open network tab and see that the js loads multiple times.

Most helpful comment

@jasonfedor regardless of that, it is wrong for someone looking to improve pagespeed score. Even adwords campaigns are costlier when page load speed in slow.

On one hand google pagespeed complains of reducing number of request and here recaptcha is unnecessarily adding an extra request for same file.

One request is being initiated by https://www.google.com/recaptcha/api.js and another by https://www.google.com/recaptcha/api2/anchor

If anyone finds any workaround to this mess then please post here.

All 6 comments

It can be replicated on their own demo as well:
https://recaptcha-demo.appspot.com/recaptcha-v2-invisible.php

And, not only the recaptcha__en.js file is being loaded several times, but also their fonts:
Screenshot 2019-10-30 11 44 00

JS:
Screenshot 2019-10-30 11 44 23

reCAPTCHA runs in multiple different frames, which requires resources to be loaded in each. This file is cached heavily though so should require <= 1 network call to load assuming caching is turned on.

@jasonfedor regardless of that, it is wrong for someone looking to improve pagespeed score. Even adwords campaigns are costlier when page load speed in slow.

On one hand google pagespeed complains of reducing number of request and here recaptcha is unnecessarily adding an extra request for same file.

One request is being initiated by https://www.google.com/recaptcha/api.js and another by https://www.google.com/recaptcha/api2/anchor

If anyone finds any workaround to this mess then please post here.

This file is cached heavily though so should require <= 1 network call to load assuming caching is turned on.

@jasonfedor This is no longer true now that Chrome implements triple-keyed cache partitioning. The resource will now be downloaded multiple times, because the various iframes don't share a cache. And it won't be cached between origins either, so it will be re-downloaded it for every site that's visited.

This can be easily verified in Google's own demo page: https://www.google.com/recaptcha/api2/demo

I believe this warrants reopening this issue.

Please do something with that. In addition to the multiple requests for js the reCaptcha stuff consume 15 to 28 requests on my sites (the higher number may be because I use 2 reCaptchas?). That is real #perfmatters

This is actually an issue for us too.
Multiple loads ( both for js and css ) and lowering of page score.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

raphj picture raphj  路  10Comments

luckyvs1 picture luckyvs1  路  9Comments

dianeensey picture dianeensey  路  3Comments

Chaython picture Chaython  路  5Comments

leetoufong picture leetoufong  路  7Comments