1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to optimize page speed and security on WP without plugins

Discussion in 'White Hat SEO' started by JWQQQ, Dec 3, 2016.

Tags:
  1. JWQQQ

    JWQQQ Junior Member

    Joined:
    Oct 24, 2012
    Messages:
    100
    Likes Received:
    26
    Here's some code snippets you can add to your functions.php file to increase security, remove footprints and increase page speed. There are plugins that do this stuff, but imo it's easier to avoid plugins and stick to code.


    PHP:
    //remove emojis
    remove_action'wp_head''print_emoji_detection_script');
    remove_action'wp_print_styles''print_emoji_styles' );

    PHP:
    //remove login errors
    add_filter('login_errors',create_function('$a'"return null;"));
    PHP:
    //remove junk code from the head
    remove_action('wp_head''wp_generator');
    remove_action('wp_head''wlwmanifest_link');
    remove_action('wp_head''rsd_link');
    remove_action('wp_head''wp_generator');
    remove_action('wp_head''start_post_rel_link');
    remove_action('wp_head''index_rel_link');
    remove_action('wp_head''feed_links_extra');
    remove_action('wp_head''feed_links');
    remove_action('wp_head''parent_post_rel_link'10);
    remove_action('wp_head''start_post_rel_link'10);
    remove_action('wp_head''adjacent_posts_rel_link_wp_head'100);
    Code:
    //Remove query string from static resources, page speed
    
    //Remove query string from static resources
    function _remove_script_version( $src ){
        if ( strpos( $src, 'ver=' ) )
            $src = remove_query_arg( 'ver', $src );
        return $src;
    }
    add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
    add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
    

    These four are the most important ones imo, but there's plenty more you can do. Source for the code: https://tobiesen.com/wordpress/
     
    • Thanks Thanks x 2
  2. DonCPAMentor

    DonCPAMentor Junior Member

    Joined:
    Apr 6, 2016
    Messages:
    145
    Likes Received:
    12
    Gender:
    Male
    Occupation:
    Affiliate Marketer
    Location:
    Chicago
    Test with both techniques.
     
  3. abhi007

    abhi007 Jr. VIP Jr. VIP

    Joined:
    Aug 31, 2010
    Messages:
    5,794
    Likes Received:
    3,917
    Location:
    Theatre of dreams :)
    This should be the right way without using plugins.
     
  4. danbarqami

    danbarqami Junior Member

    Joined:
    Jan 6, 2016
    Messages:
    167
    Likes Received:
    28
    Thanks that is extremely useful!
     
  5. ContentWriter

    ContentWriter Jr. VIP Jr. VIP

    Joined:
    May 8, 2013
    Messages:
    2,908
    Likes Received:
    382
    Occupation:
    Content Writer
    Home Page:
    Which of the four did you try and did it work?
     
  6. Street Fighter

    Street Fighter Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 4, 2015
    Messages:
    1,073
    Likes Received:
    228
    Gender:
    Male
    Occupation:
    Link Builder
    Location:
    In Street
    will check and update