1

I noticed that when loading my website, it tries to fetch something from polyfill.io which severly slows down loading time and is potentially harmful. I can see two links in the source code of every page. It is a 1) DNS prefetch and 2) trying to grab a script.

image of polyfill links in the source code of my pages

I tried to find these links in functions.php of my theme and in other files but with no success. What can I do to remove them completely or replace with, for example Cloudshare's polyfill library? (I'm not a Cloudshare's user).

I already tried some code found here on Stack but it only got rid of the DNS prefetch, without deleting the second link that tries to grab a script from polyfill.io. For now, I removed this code from functions.php, but I am pasting it here for reference:

function remove_polyfill() {
wp_dequeue_script('wp-polyfill');
wp_deregister_script('wp-polyfill');
}
add_action('wp_enqueue_scripts', 'remove_polyfill', 100);

function remove_intersection_observer_polyfill() {
wp_dequeue_script('intersection-observer-pollyfill');
wp_deregister_script('intersection-observer-pollyfill');
}
add_action('wp_enqueue_scripts', 'remove_intersection_observer_polyfill', 100);

function remove_unwanted_assets() {
// Remove DNS prefetch link
remove_action('wp_head', 'wp_resource_hints', 2);

// Dequeue and deregister Intersection Observer polyfill script
wp_dequeue_script('intersection-observer-polyfill-js');
wp_deregister_script('intersection-observer-polyfill-js');
}
add_action('wp_enqueue_scripts', 'remove_unwanted_assets', 100);

Thank you for any advice.

0