sinanisler logo

Remove jQuery and Front-End Libs WordPress for Optimization

Sometimes you need to remove the front-end libraries to make the WP load faster for visitors.

But be careful some plugins may need some of these libraries.


function remove_jquery() {
    if (!is_admin()) { // Ensure jQuery is still available in admin area
        wp_deregister_script('jquery'); // De-register jQuery
        wp_register_script('jquery', '', '', '', true); // Register a dummy jQuery script
add_action('wp_enqueue_scripts', 'remove_jquery');

Remove WP Embed Script

function disable_embeds_code_init() {
    remove_action('rest_api_init', 'wp_oembed_register_route');
    remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10);
    remove_action('wp_head', 'wp_oembed_add_discovery_links');
    remove_action('wp_head', 'wp_oembed_add_host_js');
add_action('init', 'disable_embeds_code_init', 9999);

Disable Emojis

remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');

Remove Dashicons in Frontend

add_action('wp_enqueue_scripts', function() {
    if (!is_user_logged_in()) {

Leave the first comment