disable "preconnect href=https://fonts.gstatic.com ..." #22505
tbba
started this conversation in
Feature Request
Replies: 1 comment
-
You can disable the preload using the following: add_action( 'template_redirect', function () {
try {
$inst = Elementor\Plugin::instance();
remove_action( 'wp_head', [ $inst->frontend, 'print_google_fonts_preconnect_tag' ], 8 );
remove_action( 'wp_head', 'wp_preload_resources', 1 );
remove_action( 'wp_head', 'wp_resource_hints', 2 );
} catch (Exception $e) {
echo "-- ERROR: $e ---";
}
}, 20); Place this in a PHP file somewhere (either functions.php or using some plugin). This disables Elementor's tag, but also automatically generated tags by WP (WordPress automatically generates those, even if you replace them using e.g. Local Google Fonts plugin) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Prerequisites
What problem is your feature request going to solve? Please describe.
The header tag "preconnect href=https://fonts.gstatic.com ..." is not acceptable in the EU (GDPR).
Describe the solution you'd like
The header tag "preconnect href=https://fonts.gstatic.com ..." is not enabled if "Google Fonts" are disabled in Elementor.
I also know that Elementor can host Google fonts locally. Fully understood.
But importing Google fonts can be a tedious task and slow down development.
Sometimes I want Google Fonts ON (for rapid development) and have a plugin "Local Google Fonts" downloading and collection the external Google fonts it finds.
That mentioned module (and others of the same kind) works perfectly, but a plugin just cannot disable Elementor's "preconnect href=https://fonts.gstatic.com ...", but leave Google Fonts ON in elementor, can it?
So still information is leaked to Google which is a GDRR offense, even if the Plugin loads fonts locally (which makes the preconnect also obsolete).
Describe alternatives you've considered
I would love an easy code for function.php to disable "preconnect href=https://fonts.gstatic.com ...".
Additional context
Or is there a way already and I just did not see it? - Please let me know.
Beta Was this translation helpful? Give feedback.
All reactions