1. This website uses cookies to improve service and provide a tailored user experience. By using this site, you agree to this use. See our Cookie Policy.
    Dismiss Notice

✅WORDPRESS OPTIMIZATION GUIDE! FROM 3 TO 1 SECOND LOAD-TIME❗❗

Discussion in 'White Hat SEO' started by FatBee, May 10, 2020.

  1. FatBee

    FatBee Jr. VIP Jr. VIP

    Joined:
    Apr 4, 2015
    Messages:
    1,801
    Likes Received:
    1,181
    Gender:
    Male
    Occupation:
    ⬇️Free Wordpress Optimization⬇️
    Location:
    ⚠️Are you lazy? I can do it for $49.99⚠️
    Home Page:
    I will try to keep this simple and quick as possible. So let's go!


    Starting Point:
    upload_2020-5-10_7-54-37.png
    upload_2020-5-10_7-58-10.png
    upload_2020-5-10_7-59-21.png

    Details about the page:
    - Namecheap Stellar Business (don't judge me, my Stellar Plus was turning shit so I manage to get $25 off on top of their active promotion, so grabbing this for $26~ a year is great!)
    - Medium Size Theme (Almost LIGHT but not really)
    - Running 16 Plugins
    - 5 Posts as of now.
    - All tests are performed on the homepage.

    LET'S GO!

    - WPRocket

    I would highly suggest running WPRocket The plugin is a killer!
    I wouldn't go with complete set up for this one cause for some users my settings might be conflicting.

    USE CLOUDFLARE (At least, Cloudflare is what I use.)

    I will focus on Prefetch DNS Requests.

    You can reduce latency by setting DNS Lookups to perform in the background with DNS prefetching
    You can set this for assets such as Google Analytics, Font Awesome, Google Fonts, and others.
    You can use https://prefetch.xyz/ too see where your website is sending requests, but if this fails for you (cause it did for me and its missing at least a few more here is a full list, compare it to your website and add what you need.)

    Code:
    //maps.googleapis.com
    //maps.gstatic.com
    //fonts.googleapis.com
    //fonts.gstatic.com
    //ajax.googleapis.com
    //apis.google.com
    //google-analytics.com
    //www.google-analytics.com
    //ssl.google-analytics.com
    //youtube.com
    //api.pinterest.com
    //cdnjs.cloudflare.com
    //pixel.wp.com
    //connect.facebook.net
    //platform.twitter.com
    //syndication.twitter.com
    //platform.instagram.com
    //disqus.com
    //sitename.disqus.com
    //s7.addthis.com
    //platform.linkedin.com
    //w.sharethis.com
    //s0.wp.com
    //s1.wp.com
    //s2.wp.com
    //s.gravatar.com
    //stats.wp.com
    //www.googletagmanager.com
    //www.googletagservices.com
    //adservice.google.com
    //pagead2.googlesyndication.com
    //tpc.googlesyndication.com
    //bp.blogspot.com
    //1.bp.blogspot.com
    //2.bp.blogspot.com
    //3.bp.blogspot.com
    //4.bp.blogspot.com
    //ajax.microsoft.com
    //ajax.aspnetcdn.com
    //s3.amazonaws.com
    //code.jquery.com
    //stackpath.bootstrapcdn.com
    //use.fontawesome.com
    //player.vimeo.com
    //github.githubassets.com
    //referrer.disqus.com
    //c.disquscdn.com
    //0.gravatar.com
    //2.gravatar.com
    //1.gravatar.com
    //ad.doubleclick.net
    //googleads.g.doubleclick.net
    //stats.g.doubleclick.net
    //cm.g.doubleclick.net
    //stats.buysellads.com
    //s3.buysellads.com
    //fonts.googleapis.com/
    As I said before, prefetch.xyz might not show everything, so what you need to do is Open DevTools (F12 on Chrome) and refresh your browser, you will see almost every single request. Cross-check them with the list and make your own, I mean there is no reason to Prefretch buysellads if you don't run buysell ads.


    - Imagify
    Imagify is a plugin that compresses and convert your images, it's a pretty neat one! Here are the settings that I use.

    upload_2020-5-10_9-6-11.png
    upload_2020-5-10_9-6-32.png
    Yes, I go with the webp format since its lighter but keeps the quality good and the size waaaaay lower that PNG or JPG can go. This is really optional if you don't like the WEBP just disable it.


    - Serve static content from a subdomain. AKA cookie-free domain!

    This will greatly reduce the service time of your static content there for the load time will gain boost!
    This is a bit technical and I strongly advise to make a backup before proceeding to this.

    Let's start with the cPanel (aka subdomain creation)

    1. Go to your cPanel > Subdomains > Create a Subdomain
    2. I will name the subdomain as static (static.website.tld)
    3. Change Document Root to public_html/wp-content
    4. if you are using Cloudflare go to your Cloudflare dashboard and add new record A, name it static and point it to your IP.
    upload_2020-5-10_9-20-6.png
    5. Now, look for wp-config.php and insert the following lines


    Code:
    /** Cookie-Free Domain. */
    define("WP_CONTENT_URL", "https://static.website.tld");
    define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] );

    I guess I don't need to tell you to change "website.tld" to your domain name.

    6. Now you must redirect all the posts to the new subdomain. Simply, run the following command in the SQL Database via phpMyAdmin.

    Code:
    UPDATE wp_posts SET guid = REPLACE(guid,'website.tld/wp-content/','static.website.tld/')
    Code:
    UPDATE wp_posts SET post_content = REPLACE(post_content,'website.tld/wp-content/','static.website.tld/')
    
    upload_2020-5-10_9-55-26.png


    7. After completing all of these steps, go to your page and refresh it. See if there is any error.

    EXPECTED ERROR: Problem loading web fonts, FontAwesome, etc. due to CORS policies

    8. (Fix) I'm using RankMath for this one. But you can edit it directly or with any other plugin that can do it.

    Go to your .httaccess file and add the following on the top line.
    Code:
    #CORS FIX
    <IfModule mod_headers.c>
     <IfModule mod_rewrite.c>
        SetEnvIf Origin "http(s)?://(.+\.)?(static.website\.com|website\.com)(:\d{1,5})?$" CORS=$0
        Header set Access-Control-Allow-Origin "%{CORS}e" env=CORS
        Header merge  Vary "Origin"
     </IfModule>
    </IfModule>
    #CORS FIX END
    Note: Change "website" to your domain name and ".com" to your own TLD.



    - Prevent Contact Form 7 from loading on every page.

    I don't know why is this, but it happens a lot and what's weird it's not on every WP installations. 3 of 5 of my websites have this issue. This is a pretty simple one.

    1. Go to functions.php (public_html/wp-includes)
    2. Add the following code on the bottom.
    PHP:
    // Remove contact form 7
    add_filter'wpcf7_load_js''__return_false' );
    add_filter'wpcf7_load_css''__return_false' );
    add_action('wp_enqueue_scripts''load_wpcf7_scripts');
    function 
    load_wpcf7_scripts() {
      if ( 
    is_page('contact') ) {
        if ( 
    function_exists'wpcf7_enqueue_scripts' ) ) {
          
    wpcf7_enqueue_scripts();
        }
        if ( 
    function_exists'wpcf7_enqueue_styles' ) ) {
          
    wpcf7_enqueue_styles();
        }
      }
    }
    If you have CF7 on multiple pages, change " if ( is_page('contact') ) {" to "if ( is_page('contact|page1|page2|page3') ) {"



    - Remove version entirely from the source files

    WPRocket should do the job with this, but if you have css/js files that are excluded WPRocket won't touche them in any way, so this one is coming in handy to those files.
    1. Go to functions.php (public_html/wp-includes)
    2. Add the following code on the bottom.

    Code:
    // Remove version entirely from the source files
    function sh_remove_ver_css_js( $src_file ) {
        if ( strpos( $src_file, 'ver=' ) )
            $src_file = remove_query_arg( 'ver', $src_file );
        return $src_file;
    }
    add_filter( 'style_loader_src', 'sh_remove_ver_css_js', 9999 );
    add_filter( 'script_loader_src', 'sh_remove_ver_css_js', 9999 );
    Time for results after doing all these simple neat tricks that are done in 10 Minutes after doing it a few times.

    upload_2020-5-10_10-44-54.png
    upload_2020-5-10_10-46-21.png
    upload_2020-5-10_10-46-35.png

    Thats it folks.
     
    • Thanks Thanks x 61
    Last edited by a moderator: May 11, 2020
  2. ziko12345

    ziko12345 Elite Member

    Joined:
    Sep 29, 2019
    Messages:
    1,501
    Likes Received:
    630
    Gender:
    Male
    Thanks, i will definetly be needing this when i start my wordpress site
     
  3. thescrrr

    thescrrr Jr. VIP Jr. VIP

    Joined:
    Apr 21, 2015
    Messages:
    1,945
    Likes Received:
    1,666
    Gender:
    Male
    Occupation:
    ✅⛔Make Your First Sale on Reddit⛔✅
    Location:
    ▼▼▼Check The Link Below▼▼▼
    Home Page:
    Bookmarked it for later, seems like a solid guide.
     
  4. Mr Positive

    Mr Positive Jr. VIP Jr. VIP

    Joined:
    Mar 30, 2018
    Messages:
    5,506
    Likes Received:
    2,638
    Gender:
    Male
    Occupation:
    If you need an extensive review I’m your guy.
    Location:
    I Post Reviews under 12 Hours
    Home Page:
    1) hey do I need to purchase a domain for the sub domain or is it free, secondly what about backlinks on the main domain will it get effected, 3) what will show up in search when users click site. www.site.com or static.siye,com
     
  5. FatBee

    FatBee Jr. VIP Jr. VIP

    Joined:
    Apr 4, 2015
    Messages:
    1,801
    Likes Received:
    1,181
    Gender:
    Male
    Occupation:
    ⬇️Free Wordpress Optimization⬇️
    Location:
    ⚠️Are you lazy? I can do it for $49.99⚠️
    Home Page:
    I don't have Pingdom before screenshot, but I just test it under US location...
    upload_2020-5-10_10-56-9.png
     
    • Thanks Thanks x 1
  6. Leon.Ken

    Leon.Ken Newbie

    Joined:
    Nov 25, 2019
    Messages:
    21
    Likes Received:
    2
    Thank you for the great post! I am using wp and Contact Form 7 for many websites but never notice the plugin will be loaded on every page, will try your method to optimize.
    I wrote a plugin recently to do auto-post work, but it blocked my server's php7.2-fpm process. After many days of searching fix on the internet, finally, I find out it is not my plugin's fault, but caused by WP's corn jobs. So do not forget to turn off corn jobs, if you don't need it. Add the following line in WP config file to disable it.

    define('DISABLE_WP_CRON', 'true');

    So for it is the biggest optimization for me.
     
  7. J K

    J K Newbie

    Joined:
    Nov 9, 2017
    Messages:
    33
    Likes Received:
    7
    Gender:
    Male
    I am facing exactly same issue, although google recently said that speed will not be considered as ranking factor however, this is still very useful for smooth user experience. very much for sharing. :)
     
  8. BuildMoreLinks

    BuildMoreLinks Jr. VIP Jr. VIP

    Joined:
    Jun 7, 2012
    Messages:
    3,085
    Likes Received:
    960
    wow, this is really detailed. Thanks a lot for sharing.
     
  9. FatBee

    FatBee Jr. VIP Jr. VIP

    Joined:
    Apr 4, 2015
    Messages:
    1,801
    Likes Received:
    1,181
    Gender:
    Male
    Occupation:
    ⬇️Free Wordpress Optimization⬇️
    Location:
    ⚠️Are you lazy? I can do it for $49.99⚠️
    Home Page:
    1. No, you don't. Just create subdomain under your existing domain name.
    2. No, you are only redirecting/changing the static files and not the whole website. So only the images/content (not text) is affected)
    3. static.domain.tld wont be indexed, only images from that domain will be indexed. But over time (I THINK) google will swap the old domain IMG URL's that are indexed to the new subdomain.
     
    • Thanks Thanks x 1
  10. TheVigilante

    TheVigilante Jr. VIP Jr. VIP

    Joined:
    Aug 31, 2010
    Messages:
    11,724
    Likes Received:
    9,362
    Occupation:
    ⛔ EPIC SEO Content! ✅▼▼▼
    Location:
    ⛔ 20% OFF - ENDS SOON ⛔
    Home Page:
    Dope share
     
  11. Xdfffninja

    Xdfffninja Registered Member

    Joined:
    Jan 13, 2019
    Messages:
    58
    Likes Received:
    23
    Bookmarked. Thanks for the share mate.
     
  12. FatBee

    FatBee Jr. VIP Jr. VIP

    Joined:
    Apr 4, 2015
    Messages:
    1,801
    Likes Received:
    1,181
    Gender:
    Male
    Occupation:
    ⬇️Free Wordpress Optimization⬇️
    Location:
    ⚠️Are you lazy? I can do it for $49.99⚠️
    Home Page:
    WPRocket is running of WPCron, and most auto takes are dependent on that, so yeah in 90% of the cases you will need it. Also, cron is run periodically so it won't affect the site speed when its not running.
     
  13. TooCorny

    TooCorny Jr. VIP Jr. VIP

    Joined:
    Sep 9, 2018
    Messages:
    671
    Likes Received:
    211
    Gender:
    Male
    Always wondered how to do the cookie free domain thing.

    What does it actually do btw?
     
  14. imanseptian

    imanseptian Power Member

    Joined:
    Mar 22, 2018
    Messages:
    615
    Likes Received:
    246
    Gender:
    Male
    Occupation:
    A Father and Internet Marketer
    Location:
    wkwkwk-land
    Home Page:
    Are you testing this on your front page, or to one of your post pages?

    Because my front page has a score of about 96. But my post page has a score of about 79. Do you have any idea about this?

    Anyway, thanks for this thread. I will try it in my other website.
     
  15. FatBee

    FatBee Jr. VIP Jr. VIP

    Joined:
    Apr 4, 2015
    Messages:
    1,801
    Likes Received:
    1,181
    Gender:
    Male
    Occupation:
    ⬇️Free Wordpress Optimization⬇️
    Location:
    ⚠️Are you lazy? I can do it for $49.99⚠️
    Home Page:
    Its pretty self explanatory (the config part)

    imaged served from a cookie domain are counted as cookie material/served by cookie domain.

    What the config does is separate the main domain and the subdomain. The subdomain is COOKIE FREE while every cookie that the site needs to work are served over the main domain.
     
  16. FatBee

    FatBee Jr. VIP Jr. VIP

    Joined:
    Apr 4, 2015
    Messages:
    1,801
    Likes Received:
    1,181
    Gender:
    Male
    Occupation:
    ⬇️Free Wordpress Optimization⬇️
    Location:
    ⚠️Are you lazy? I can do it for $49.99⚠️
    Home Page:
    The screenshots are on home page, but I'm getting ALMOST same results on post pages. Mobile is falling a bit more tho.
     
    • Thanks Thanks x 1
  17. RolandNL

    RolandNL Newbie

    Joined:
    Apr 14, 2020
    Messages:
    13
    Likes Received:
    4
    Cool guide but I don't get why you suggest to use webP format for the images. This format is NOT supported on Safari browsers. As you can see here Safari has 30% of the internet usage so you already loose 30% of your visitors https://www.stetic.com/market-share/browser/
     
  18. Mr Positive

    Mr Positive Jr. VIP Jr. VIP

    Joined:
    Mar 30, 2018
    Messages:
    5,506
    Likes Received:
    2,638
    Gender:
    Male
    Occupation:
    If you need an extensive review I’m your guy.
    Location:
    I Post Reviews under 12 Hours
    Home Page:
    Do we need add any settings in cloudflare?
     
  19. Wolfy Ofspring

    Wolfy Ofspring Junior Member

    Joined:
    May 30, 2019
    Messages:
    177
    Likes Received:
    27
    Gender:
    Female
    Location:
    British Columbia, Canada
    Great share
     
  20. godknowseverything

    godknowseverything Power Member

    Joined:
    Oct 13, 2014
    Messages:
    527
    Likes Received:
    928
    Gender:
    Male
    Occupation:
    Coiner
    Location:
    Planet SEO
    Can you share the WP rocket settings?