Get almost 100% PageSpeed on Newspaper theme

81
Get almost 100% PageSpeed on Newspaper theme

The newspaper theme is a most popular premium theme for self-hosted WordPress blog. The theme is developed by team tagDiv. You can buy this theme from ThemeForest. The theme comes with great features. The theme package contains some premium plugins which are listed below –

  • Mobile theme plugin
  • TD Composer plugin
  • Js Composer plugin
  • Social Counter plugin
  • Speed Booster plugin
  • Revolution Slider plugin

Theme developers have provided a great support forum and tutorials for step by step setup. They have also provided PageSpeed guide to speed up your blog.

Here, I am going to share some simple ideas which I have learned while optimizing my own blogs.

I am considering you have self-hosted WordPress blog with Newspaper theme active.

Install WP Super Cache

WP Super Cache plugin is a recommended cache plugin by tagDiv. It serves static contents to the visitor which improve page load speed.

Setup CloudFlare

CloudFlare is a free CDN which cache all the resources from your website and serve them to the users from their servers which are located across the globe. This reduces the load time of your website.

Options you have to enable on CloudFlare’s dashboard.

In your CloudFlare’s dashboard go to speed option. In the Auto minify check for-

  • JavaScript
  • CSS
  • HTML

minify_cloudflare

Scroll down, under the Rocket Loader settings, check Automatic this will improve load time for pages that include JavaScript.

enable-rocket-loader

Browser Caching – Add Expire Headers to WordPress

We are almost done here, now will go with sensitive part of this tutorial. You have to modify the code in .htaccess the file. If anything goes wrong while editing, .htaccess your site may show a blank page or Error 500.

You have to add below code to your .htaccess file. Just copy and paste the following code-

# BEGIN Expire headers
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
ExpiresByType image/x-icon "access plus 604800 seconds"
ExpiresByType image/jpeg "access plus 604800 seconds"
ExpiresByType image/png "access plus 604800 seconds"
ExpiresByType image/gif "access plus 604800 seconds"
ExpiresByType application/x-shockwave-flash "access plus 604800 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 604800 seconds"
ExpiresByType application/javascript "access plus 604800 seconds"
ExpiresByType application/x-javascript "access plus 604800 seconds"
ExpiresByType font/truetype "access plus 604800 seconds"
ExpiresByType font/opentype "access plus 604800 seconds"
ExpiresByType application/x-font-woff "access plus 604800 seconds"
ExpiresByType image/svg+xml "access plus 604800 seconds"
ExpiresByType application/vnd.ms-fontobject "access plus 604800 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</ifModule>
# END Expire headers

<IfModule mod_deflate.c>
<filesMatch "\.(js|css|woff|html|php)$">
SetOutputFilter DEFLATE
</filesMatch>
</IfModule>

NOTE: If you have Optimize Website module enabled. It is located in your cPanel under Software. Then just remove the following code from a .htaccess file. It is highlighted with red color in the above code.

<IfModule mod_deflate.c>
<filesMatch "\.(js|css|woff|html|php)$">
SetOutputFilter DEFLATE
</filesMatch>
</IfModule>

Fix The admin-ajax.php Slow Problem

As discussed with the tagDiv team it confirmed that theme uses admin-ajax.php almost for every block to request the Server and many of the features themes uses this way to query the server and may increase WordPress server load time.

So, to reduce admin-ajax requests trim down the block ajax options meaning the blocks pagination and ajax filters. Turn off the Ajax view count. Also, make sure you do not use too many different types of blocks. It’s better to check my guide to reduce admin-ajax server load in WordPress.

Enable Lazy Load

The theme comes with lazy load feature. Enabling lazy load can reduce numbers of requests.

Install tagDiv Speed Booster plugin

tagDiv speed booster plugin comes with Newspaper theme bundle. It compresses all the Stylesheets and JavaScript and moves them to the bottom of the page. This will Eliminate render-blocking JavaScript and CSS.

Removing Font Awesome

To use icons in the theme, you have to use Font Awesome plugin. There are a LOT of icons, and if you’re not using them, then there’s no point in loading all of them.

You need some of these icons for various elements throughout the theme. So you can add a little filter to script so that it only loads essentials.

To do so, put the following code in your theme’s functions.php file.

//Load Essential Fonts Awesome
add_filter( 'infophilic_fontawesome_essentials', 'infophilic_fontawesome_essentials' );
function infophilic_fontawesome_essentials()
{
 return true;
}

Removing Emojis

If you not using Emojis on your site then there’s no need to load them in the back-end. So you can remove it by adding following code in theme’s functions.php

//Removing Emojis
add_action( 'init', 'infophilic_disable_wp_emojicons' );
function infophilic_disable_wp_emojicons() 
{
 // all actions related to emojis
 remove_action( 'admin_print_styles', 'print_emoji_styles' );
 remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
 remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
 remove_action( 'wp_print_styles', 'print_emoji_styles' );
 remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
 remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
 remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
}

Removing other scripts

Newspaper theme comes with inbuilt embed script so there’s no need to use embed script by the core WordPress. It’s it better to deregister by adding following code to the end of your theme’s functions.php file. This will also reduce HTTP requests to the server.

// Remove WP embed script
function infophilic_stop_loading_wp_embed() {
if (!is_admin()) {
wp_deregister_script('wp-embed');
}
}
add_action('init', 'infophilic_stop_loading_wp_embed');

Remove Scripts by Jetpack

Jetpack is one of the best plugins to enhance functionality and the security of your WordPress site. Jetpack’s single sign-on (SSO) feature is the best option to deal with the brute force attacks. Use my guide to enable single sign-on for your WordPress site. But the scripts and the CSS that been loading by Jetpack are not necessary for this. So it’s better to remove them. Add the following code to your theme’s functions.php to remove scripts by Jetpack plugin.

//Remove Jetpack css
add_filter( 'jetpack_implode_frontend_css', '__return_false' );

//Remove Jetpack script 
function jeherve_dequeue_devicepx() {
wp_dequeue_script( 'devicepx' );
}
add_action( 'wp_enqueue_scripts', 'jeherve_dequeue_devicepx' );

Removing Multipurpose Plugin CSS

In last update tagDiv and combined td-composer and multipurpose plugin so it’s a good idea to remove the style loaded by the plugin if you are not using any module that is provided by the multipurpose plugin. Add the following code to your child theme’s functions.php file.

//Remove Multi Purpose Style
add_action( 'wp_enqueue_scripts', 'infophilic_remove_multi_purpose', 20 );
function infophilic_remove_multi_purpose() {
wp_dequeue_style( 'td-plugin-multi-purpose' );
}

Conclusion

That’s it, you are done with the optimization now check your website’s performance score at GTMetrix.com. I am sure you are much satisfied with the speed. If you stuck somewhere feel free to drop a comment below.

Hey, wait!!
Don’t forget to share this tutorial on your social networks.  Thanks for reading 🙂

81 COMMENTS

  1. Hi Amit, I followed all your steps but still have "elements that must be corrected:" do not know where and how to add these images and files so they are cached at least 31 days for example:
    http://sumome.com/api/load/ (not specified expiration time)
    https://shield.sitelock.com/shield/trebol-apuestas.com (not specified expiration time)
    ….

    Here you can see my pagespeed
    https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fwww.trebol-apuestas.com%2F&tab=mobile

    You can help me a little more

  2. Thanks Amit for the Tutorial. The object-cache.php returned error and turn my site off. I have set others as stated but the search function seems not working anymore on desktop version. You can check the demo by clicking on my name. What next???

  3. I am using cloudflare and wp rocket for caching and getting like a 98/100 but the search, more from author, infinite load wont work unless cloudflare rocketscript it off which then takes my page load time way up. I downloaded wp super cache and tried your way and I get an F score on gtmetrix. Any idea why?

  4. Hello Amit, I came here from Newpaper forum. Really appreciate your input. Our site mayapurvoice was shown green (score around 85) in Google page speed insight but after upgrading either some plugin/s or the theme itself the speed score plummeted to below 60 (couldn't ascertain the culprit although I tried disabling plugins and stuff.. will try downgrading the theme if nothing works).

    I went through your suggestions and they all make sense to me but I have a question before I install Could flare. Do you know if this plugin doesn't bring a desired result and if I disable and delete it, will it undo the changes it may have done to my theme and other settings? I ask this because one security plugin screwed up my .htaccess file and although I deleted the plugin, it didn't put back my original .htaccess file. Not only that, the plugin didn't even create (or at least I couldn't find) a back up of that file and I had to re-enter some entries manually. Perhaps that also has affected my page speed but I am not sure. On top of that, I spent days before finding it to be the reason for my cron job issues. Anyway that's a side point.

    The number of posts and images on our homepage should not be a real issue as more or less the same were there when it was in green.

    Your input will be useful. Thanks again for the post on Newspaper forum and here.

    • Hello Mayapur,

      I have inspected your site, It's loading fine on my end. All you need to optimize images on your website. It will surely add some positive points to Google page speed score.

      Now coming to the CloudFlare query, it will not damage your site. All you need to follow this tutorial https://goo.gl/1qCXdP

      Installing CloudFlare plugin doesn't change any existing file (.htaccess) on your server.

  5. Hello

    Newspaper 7 recommends disabling Rocket Loader for the incompatibility it causes. What you did to fix this, for example the search button gets error and several other things.

    • Don't over minify the scripts, use CloudFlare alone for the minification. And purge all the cache. If you face image loading issue on successful activation of Rocket loader, reactivating Image load animation (Lazy load) from the theme control panel.

  6. Very super article and it was very helpful for increasing the frontpage. However, almost all of the tests-increase your site speed tutorials are based on the frontpage and it's about the article because they have to rank. Upon I speed test an individual post the results turned into red. Al lot of scripts are in the header.

  7. Hi, Amit,
    Great article. I went through all your suggestions but the strange thing is that when I complete most of the steps the Pages Speed according to Google is 70+, but the site is loading slower. If I disable WP Super Cache and stop using Gzip compression via the .htaccess, the site score is really low (30), but it seems to load faster. Any ideas why this happens? The site is blog.hotel-extreme.bg

    • @ChrisVelev:disqus

      Thank you for the appreciation.
      I have checked your site and found you are not using CloudFlare.
      Only enable Gzip with a single setup. I recommend you to install WP Super Cache plugin without adding Gzip code on .htaccess and remove other expiry header code from it.
      Note:
      1. Cache plugin takes some time to build all the cache.
      2. You can use my tutorial for WP Super Cache settings here: https://www.infophilic.com/install-setup-wp-super-cache/

      • Thanks,
        I also installed WP Super cache with the settings you recommend and the site is loading slower, but the score on Page speed insights is better? Not sure why this is happening? Any idea how long it takes to build up all the cache?

  8. Come on Speed Booster is a TOTAL JOKE! There are NO compatabilities. I removed 7 plugins and it just kept saying disabled, yet another thing isn't compatable.

    • You have to add them to the exception in order to make Speed booster work. But I have removed this plugin because i am using it on cloudflare already. So why double minifying it and the less plugins you're using the better it is.
      It's or speed booster or Cloud flare, not speed booster and cloud flare.

  9. Hello Amit!

    I have to say, this is exciting to see! My site seems to have some problems that I cannot seem to figure out. http://www.rootfantasysports.com – I did most of what you said, however, I couldn't figure out what you meant by "disable object cache" and the ajax issue I do not understand and how to do. Furthermore, I am encountering an even bigger issue. My mobile site (apparently, just the Home (front) page ONLY loads code…how can this be?? How did this happen? Please help if you can!

    Thank you!

    • Hello Andrew,
      I have checked your site. There is no issue related to the admin-ajax.php file.
      To fix your mobile site issue, Go to Jetpack settings and disable mobile theme feature. That’s it.

      Have a great day.

  10. If I use the wprocket plugin
    So do I need to use this code?
    # BEGIN Expire headers

    ExpiresActive On
    ExpiresDefault "access plus 5 seconds"
    ExpiresByType image/x-icon "access plus 604800 seconds"
    ExpiresByType image/jpeg "access plus 604800 seconds"
    ExpiresByType image/png "access plus 604800 seconds"
    ExpiresByType image/gif "access plus 604800 seconds"
    ExpiresByType application/x-shockwave-flash "access plus 604800 seconds"
    ExpiresByType text/css "access plus 604800 seconds"
    ExpiresByType text/javascript "access plus 604800 seconds"
    ExpiresByType application/javascript "access plus 604800 seconds"
    ExpiresByType application/x-javascript "access plus 604800 seconds"
    ExpiresByType font/truetype "access plus 604800 seconds"
    ExpiresByType font/opentype "access plus 604800 seconds"
    ExpiresByType application/x-font-woff "access plus 604800 seconds"
    ExpiresByType image/svg+xml "access plus 604800 seconds"
    ExpiresByType application/vnd.ms-fontobject "access plus 604800 seconds"
    ExpiresByType text/html "access plus 600 seconds"
    ExpiresByType application/xhtml+xml "access plus 600 seconds"

    # END Expire headers

    SetOutputFilter DEFLATE

  11. Thanks for this great tutorial, Amit! 😀

    One question — when updating the function.php file, do I copy-paste the filtering code into the file with the references to 'infophilic'?
    Are those recognized by Newspaper theme… or am I missing something?!?

    Thanks!
    Ian

  12. Hi Amit, congratulations for the article. I installed the template on ecomesifa, but the speed on mobile is always 74. If I try to activate the JS defer on the litespeed cache plug-in, the menu button and the search will not work on mobile. Do you have any idea?? Thank you

  13. Hello, I use WP super cache. Do I need to disable it if I want to use CDN? Do I need to remove everything from my .htaccess if I am going to use CDN?

      • Thanks. I have put this to my .htaccess file.
        # BEGIN WordPress
        <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^index\.php$ – [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
        </IfModule>

        # END WordPress

        # BEGIN cPanel-generated php ini directives, do not edit
        # Manual editing of this file may result in unexpected behavior.
        # To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
        # For more information, read our documentation
        <IfModule php5_module>
        php_flag asp_tags Off
        php_flag display_errors On
        php_value max_execution_time 180
        php_value max_input_time 60
        php_value max_input_vars 1000
        php_value memory_limit 256M
        php_value post_max_size 64M
        php_value session.gc_maxlifetime 1440
        php_value session.save_path "/var/cpanel/php/sessions/ea3"
        php_value upload_max_filesize 64M
        php_flag zlib.output_compression Off
        </IfModule>
        # END cPanel-generated php ini directives, do not edit

        # BEGIN Compress text files
        <IfModule mod_deflate.c>
        <filesMatch "\.(js|css|html|php)$">
        SetOutputFilter DEFLATE
        </filesMatch>
        </IfModule>
        # END Compress text files

        # BEGIN Expire headers
        <ifModule mod_expires.c>
        ExpiresActive On
        ExpiresDefault "access plus 5 seconds"
        ExpiresByType image/x-icon "access plus 604800 seconds"
        ExpiresByType image/jpeg "access plus 604800 seconds"
        ExpiresByType image/png "access plus 604800 seconds"
        ExpiresByType image/gif "access plus 604800 seconds"
        ExpiresByType application/x-shockwave-flash "access plus 604800 seconds"
        ExpiresByType text/css "access plus 604800 seconds"
        ExpiresByType text/javascript "access plus 604800 seconds"
        ExpiresByType application/javascript "access plus 604800 seconds"
        ExpiresByType application/x-javascript "access plus 604800 seconds"
        #ExpiresByType text/html "access plus 600 seconds"
        #ExpiresByType application/xhtml+xml "access plus 600 seconds"
        </ifModule>
        # END Expire headers

  14. Hi Amit, congratulations for the article. I own the website alesdonline if you have the same by teamwiver can help to increase the speed of the site? Thank you

  15. Hi Amit, congratulations for the article
    Which plugins do you recommend to minimize HTML, CSS, and js while I don't use CloudFlare. like a demo of the newspaper theme
    Thank you

  16. HI Amit, thanks for the awesome guide, my page load speed is around 2s now, i would love to give you all the creadit, here is the report https://gtmetrix.com/reports/www.pcbuilderbd.com/fWF1utxK

    On yslow, i have three recommendations, adding expiry headers is the most prioritized among them,
    I did added expiration rules according to your guide on htaccess, however the following still needs to added and im not sure how it can be done

    https://ajax.cloudflare.com/cdn-cgi/scripts/9014afdb/cloudflare-static/rocket.min.js
    https://fonts.googleapis.com/css?family=Open+Sans%3A300italic%2C400%2C400italic%2C600%2C600italic%2C700%7CRoboto%3A300%2C400%2C400italic%2C500%2C500italic%2C700%2C900&ver=8.5.1
    https://www.pcbuilderbd.com/cdn-cgi/scripts/af2821b0/cloudflare-static/email-decode.min.js

    The other suggestion they have is to use cookie free domain. What are your thoughts on using a subdomain for images?

  17. Why there is Infophilic word in many scripts that you provide

    //Load Essential Fonts Awesome
    add_filter( ‘infophilic_fontawesome_essentials’, ‘infophilic_fontawesome_essentials’ );
    function infophilic_fontawesome_essentials()
    {
    return true;
    }

  18. I don't use any cache plugin and CDN services right now. Desktop page speed is showing good but the mobile speed is 47%. Can you give me a proper suggestion? Is the CDN service necessary to use?

    • Reducing the number of scripts will help you to get better score and speed.
      If you have high traffic from different countries then you must use CDN. It will surely reduce the server load.

  19. I am using newspaper theme and installed wp super cache plugin. Can i use autoptimize for minifying css, javascript?
    Is there any problem to use the both plugin?

  20. Whenever I want to remove wp_emoji from functions.php, it is showing error like this – (Unable to communicate back with the site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.)

    What should I do??

  21. Hello Amit bro
    I followed all these steps and I found some improvement in my newspaper.
    But google webmaster tool showing me some URL error which newspaper theme. now tell me how to solve this issue.

  22. I have been practicing with CloudFlare for a while now, and essentially the goal was to improve my sites performance. The extra security is an extended bonus for me. About my opinion, it helps me a lot. I am fortunate that I chose to use their settings and now that they have added more free tools, it delivers it all high.

    I have discovered though that there are several matters as far as analytics and SEO are concerned. For better SEO, I have not observed any difference, but for statistics, it made some positive changes from improving the bounce rate to getting more subscribers. I am not so that much able to calculate those figures are especially with the integration of Google Analytics. Something I am still looking very carefully. I will see and update you.

    Though it’s been great, and I’m happy to be using CloudFlare for my writing blog. The page loading speed improvements solely are worth it, but the technique to prevent threats and the awareness that my blog will always be online are also valuable.

  23. hello, how to fix this ” http://prntscr.com/kktn81

    Your page requires additional network round trips to render the above-the-fold content. For best performance, reduce the amount of HTML needed to render above-the-fold content.
    156.8KiB of the HTML response was required to render the above-the-fold content. This requires 4 network round-trips. Prioritize the above-the-fold content so that it can be rendered with only the first 2 round-trips’ worth of HTML.
    Only about 3% of the final above-the-fold content could be rendered with the HTML delivered within 2 round-trips.
    Click to see the screenshot with 2 round trips: see screenshot
    Click to see the fully-rendered page: see fully-rendered page

LEAVE A REPLY

Please enter your comment!
Please enter your name here