Dark's Code Dump

Possibly useful

How to remove all Javascript from WordPress

Why do modern web developers insist on hundreds of kb of Javascript when it achieves literally nothing at all? Here’s how you can make WordPress load several times faster, and without breaking any functionality, assuming your use case is a simple blog + comments.

Add the following to somewhere in your theme’s shared functions file, or similar:

function remove_all_scripts()
{
    if (!is_user_logged_in())
    {
        foreach (wp_scripts()->registered as &$script)
        {
            wp_dequeue_script($script->handle);
            wp_deregister_script($script->handle);
        }
    }
}

add_action('wp_enqueue_scripts', 'remove_all_scripts', PHP_INT_MAX);

The ‘is logged in’ check facilitates the wp-admin panel among other things.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.