├── README.md └── functions.php /README.md: -------------------------------------------------------------------------------- 1 | Blog Post - https://geekflare.com/wordpress-performance-optimization-without-plugin 2 | -------------------------------------------------------------------------------- /functions.php: -------------------------------------------------------------------------------- 1 | /*Update following in your WordPress theme's functions.php file */ 2 | 3 | // Remove Query String from Static Resources 4 | function remove_cssjs_ver( $src ) { 5 | if( strpos( $src, '?ver=' ) ) 6 | $src = remove_query_arg( 'ver', $src ); 7 | return $src; 8 | } 9 | add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 ); 10 | add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 ); 11 | 12 | // Remove Emojis 13 | remove_action('wp_head', 'print_emoji_detection_script', 7); 14 | remove_action('wp_print_styles', 'print_emoji_styles'); 15 | remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); 16 | remove_action( 'admin_print_styles', 'print_emoji_styles' ); 17 | 18 | // Remove Shortlink 19 | remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0); 20 | 21 | // Disable Embed 22 | function disable_embed(){ 23 | wp_dequeue_script( 'wp-embed' ); 24 | } 25 | add_action( 'wp_footer', 'disable_embed' ); 26 | 27 | // Disable XML-RPC 28 | add_filter('xmlrpc_enabled', '__return_false'); 29 | 30 | // Remove RSD Link 31 | remove_action( 'wp_head', 'rsd_link' ) ; 32 | 33 | // Hide Version 34 | remove_action( 'wp_head', 'wp_generator' ) ; 35 | 36 | // Remove WLManifest Link 37 | remove_action( 'wp_head', 'wlwmanifest_link' ) ; 38 | 39 | // Disable JQuery Migrate 40 | function deregister_qjuery() { 41 | if ( !is_admin() ) { 42 | wp_deregister_script('jquery'); 43 | } 44 | } 45 | add_action('wp_enqueue_scripts', 'deregister_qjuery'); 46 | 47 | // Disable Self Pingback 48 | function disable_pingback( &$links ) { 49 | foreach ( $links as $l => $link ) 50 | if ( 0 === strpos( $link, get_option( 'home' ) ) ) 51 | unset($links[$l]); 52 | } 53 | 54 | add_action( 'pre_ping', 'disable_pingback' ); 55 | 56 | // Disable Heartbeat 57 | add_action( 'init', 'stop_heartbeat', 1 ); 58 | function stop_heartbeat() { 59 | wp_deregister_script('heartbeat'); 60 | } 61 | 62 | // Disable Dashicons in Front-end 63 | function wpdocs_dequeue_dashicon() { 64 | if (current_user_can( 'update_core' )) { 65 | return; 66 | } 67 | wp_deregister_style('dashicons'); 68 | } 69 | add_action( 'wp_enqueue_scripts', 'wpdocs_dequeue_dashicon' ); 70 | 71 | // Disable Contact Form 7 CSS/JS on Every Page 72 | add_filter( 'wpcf7_load_js', '__return_false' ); 73 | add_filter( 'wpcf7_load_css', '__return_false' ); 74 | 75 | --------------------------------------------------------------------------------