Polyfill

How to Remove Polyfill from WordPress

If you scan your WordPress site or check the page source, you may notice a file called polyfill.min.js loading. This file is a JavaScript library. It helps old browsers understand new features used in WordPress.

While it sounds helpful, most modern browsers no longer need it. Today, almost all visitors use updated browsers. Loading a polyfill can slow down your site. You can remove polyfill if you want to make your site faster and cleaner.

In this guide, I will show you how to remove polyfill from WordPress quickly and safely.

What Is Polyfill in WordPress?

Polyfill is a JavaScript file. WordPress uses it to ensure that older browsers can handle modern code, such as promises, fetch, and other newer JavaScript features.

The file usually loads from:

https://s.w.org/polyfill.min.js

If you want your site to load fewer files and run faster, you might not need this anymore.

How to Remove Polyfill from WordPress

There are several ways to do it. Let’s go through them one by one.

Method 1: Remove Polyfill Using Functions.php

You can add a small code snippet to your theme’s functions.php file.

Steps:

  1. Go to your WordPress dashboard
  2. Navigate to Appearance > Theme File Editor.
  3. Open the functions.php file.
  4. Add this code at the bottom:

function remove_polyfill_script() {

    remove_action( ‘wp_head’, ‘wp_polyfill_script’, 1 );

}

add_action( ‘init’, ‘remove_polyfill_script’ );

  1. Click Update File

This code tries to remove the polyfill script from loading in the header.

Method 2: Deregister the Polyfill Script

If the first method fails, you can manually deregister the script.

Steps:

  1. Open the functions.php file again
  2. Add this code:

function dequeue_wp_polyfill() {

    wp_deregister_script(‘wp-polyfill’);

}

add_action(‘wp_enqueue_scripts’, ‘dequeue_wp_polyfill’, 100);

  1. Save the changes

This tells WordPress not to load the polyfill script during page load.

Method 3: Remove Polyfill with a Custom Plugin

You can create a small plugin if you do not want to edit your theme files.

Steps:

  1. Go to your WordPress dashboard
  2. Navigate to Plugins > Add New.
  3. Click Create a New Plugin if you have the right option, or use FTP/File Manager.
  4. Create a new folder in wp-content/plugins called remove-polyfill
  5. Inside that folder, create a file named remove-polyfill.php
  6. Add this code:

<?php

/*

Plugin Name: Remove Polyfill Script

Description: Removes wp-polyfill from WordPress frontend

Version: 1.0

Author: Your Name

*/

add_action(‘wp_enqueue_scripts’, function() {

    wp_deregister_script(‘wp-polyfill’);

}, 100);

?>

  1. Save the file
  2. Go to Plugins > Installed Plugins and activate Remove Polyfill Script.

Now your site will stop loading the polyfill file without touching your theme.

Method 4: Use Asset CleanUp Plugin

If you prefer using a plugin that handles scripts easily, you can install Asset CleanUp.

Steps:

  1. Go to Plugins > Add New
  2. Search for Asset CleanUp
  3. Install and activate the plugin.
  4. Edit any page or post.
  5. Look for the list of loaded scripts.
  6. Find wp-polyfill and unload it.

This method gives you more control over which pages to remove it from.

Things to Remember

  • After removing polyfill, test your website on different browsers.
  • Make sure essential features like forms and sliders still work.
  • Always back up your site before making code changes.
  • Remove polyfill only if your users are not using ancient browsers.

Usually, removing polyfill is safe if your visitors use updated Chrome, Firefox, Safari, or Edge.

How to Check If Polyfill Is Still Loading

After you remove it, you should check if it worked.

Steps:

  1. Open your website in a browser
  2. Right-click and select View Page Source
  3. Search for polyfill.min.js

If you do not find it, the polyfill is removed successfully.

You can also use GTmetrix, Pingdom, or Chrome DevTools to check network requests.

What If You Want to Add It Back Later?

You can re-add the polyfill if something breaks or you want to support older browsers again.

You can remove the code you added to the functions.php file or deactivate the custom plugin you created. WordPress will automatically load the polyfill again.

Conclusion

Most modern WordPress websites no longer need the polyfill file. Removing it can help your site load faster and feel lighter.

You can remove it by editing the functions.php file, creating a small plugin, or using a script manager plugin. Always test your site after making changes to ensure everything works as expected.

Now you know how to remove polyfill from WordPress and make your site faster and cleaner.