wordpress 删除多余代码,加速前端加载

function clean_head()
    // remove the links to the extra feeds such as category feeds
    remove_action('wp_head', 'feed_links_extra', 3);
    // remove REST API link tag
    remove_action('wp_head', 'rest_output_link_wp_head');
    // remove the link to the Really Simple Discovery service endpoint
    remove_action('wp_head', 'rsd_link');
    // remove the link to the Windows Live Writer manifest file
    remove_action('wp_head', 'wlwmanifest_link');
    // remove rel=canonical for singular queries
    remove_action('wp_head', 'rel_canonical');
    // remove relational links for the posts adjacent to the current post for single post pages
    remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10);
    // remove shortlink
    remove_action('wp_head', 'wp_shortlink_wp_head');
    // remove oEmbed
    remove_action('wp_head', 'wp_oembed_add_discovery_links');
    remove_action('wp_head', 'wp_oembed_add_host_js');
    // 移除 wordpress 信息,防止被恶意扫描
    remove_action('wp_head', 'wp_generator');
    // 移除cdn预读
    remove_action('wp_head', 'wp_resource_hints', 2);
    // 移除emoji
    remove_action('wp_head', 'print_emoji_detection_script', 7);
    remove_action('wp_print_styles', 'print_emoji_styles');

add_action('after_setup_theme', 'clean_head');


电子邮件地址不会被公开。 必填项已用*标注

7 + 2 =