This post is about how to improve PageSpeed of Newspaper theme (page loading speed) or optimize Newspaper theme. The newspaper theme is the most popular premium theme for a self-hosted WordPress blog. The theme is developed by team tagDiv. You can buy this theme from ThemeForest (Newspaper by tagDiv). The theme comes with great features and we can easily optimize the Newspaper theme to Improve page loading speed.
The theme package contains some premium plugins which are listed below –
- tagDiv Mobile Theme + AMP
- tagDiv Standard Pack
- tagDiv Composer
- tagDiv Cloud Library
- tagDiv Social Counter
- tagDiv Newsletter
- tagDiv Opt-In Builder
- tagDiv Shop
- Revolution Slider
- WPBakery Page Builder
Theme developers have provided a great support forum and tutorials for step by step setup. They have also provided a PageSpeed guide to speed up Newspaper theme.
Here, I am going to share some simple ideas which I have learned while optimizing my website.
I am considering you have a self-hosted WordPress blog with a newspaper theme active.
Read Also: Easy Steps to create your own Website with NO coding knowledge on Bluehost
Way to optimize Newspaper theme | Improve page loading speed (improve PageSpeed of Newspaper theme)
Install WP Super Cache
WP Super Cache plugin is a recommended cache plugin by tagDiv. It serves static content to the visitor which improves page load speed.
Setup Cloudflare
Cloudflare is a free CDN that caches all the resources from your website and serves them to the users from their servers which are located across the globe. It reduces the load time of your website.
How to setup Cloudflare CDN for WordPress blog
Options you have to enable on CloudFlare’s dashboard.
In your Cloudflare dashboard go to the speed option. In the Auto minify check for-
- JavaScript
- CSS
- HTML
Browser Caching – Add Expire Headers to WordPress
We are almost done here, now we will go with the 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.
How to Edit .htaccess File on your WordPress Blog
You have to add the 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>
If you have Optimize Website module enabled. It is located in your cPanel under Software. Then remove the following code from a .htaccess file. It is highlighted 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
Newspaper by tagDiv theme uses admin-ajax.php
almost for every block to request the Server and many of the features themes use 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.
Enable Lazy Load
Newspaper lazy load is a feature that comes with the theme that can be used to lazy load all images on your blog/website. Enabling a lazy load can reduce the number of requests.
tagDiv CSS Analyzer
If you’re using Newspaper 10.4 or above version, you get a new tool – tagDiv CSS Analyzer. This tool scans your website for used CSS and creates separate files for used CSS by removing unused CSS. This tool also creates critical CSS and moves non-critical CSS to the bottom of the page.
Currently, this tool is in beta mode stills giving me promising results.
Removing Emojis
If you are 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 the following code to theme’s functions.php
// Removing Emojis
add_action( 'init', 'studywarehouse_disable_wp_emojicons' );
function studywarehouse_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
A newspaper theme comes with an inbuilt embed script, so there’s no need to use an embed script by the core WordPress. It’s better to deregister by adding the following code to the end of your theme’s functions.php
file. It will also reduce HTTP requests to the server.
// Remove WP embed script
function studywarehouse_stop_loading_wp_embed() {
if (!is_admin()) {
wp_deregister_script('wp-embed');
}
}
add_action('init', 'studywarehouse_stop_loading_wp_embed');
Remove Scripts by Jetpack
Jetpack is one of the best plugins to enhance the 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 have 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', 99 );
// Remove Devicepx script
function jeherve_dequeue_devicepx() {
wp_dequeue_script( 'devicepx' );
}
add_action( 'wp_enqueue_scripts', 'jeherve_dequeue_devicepx' );
Mobile theme optimization
A newspaper theme comes with a dedicated optimized mobile theme that can be enabled by installing a tagDiv mobile theme plugin.
The current mobile theme version does not support both, Newsletter and Multipurpose plugins. So, it is a good idea to remove these scripts being loaded by these plugins.
You can add the following code in the mobile theme’s functions.php file.
You can find the mobile theme’s functions.php
file under the path: /wp-content/plugins/td-composer/mobile/
Use this tip only if you have not disabled tagDiv mobile theme on any of your site pages.
// Remove Multi Purpose Style
add_action( 'wp_enqueue_scripts', 'studywarehouse_remove_multi_purpose', 20 );
function studywarehouse_remove_multi_purpose() {
wp_dequeue_style( 'td-plugin-multi-purpose' );
}
// Remove Newsletter Style
add_action( 'wp_enqueue_scripts', 'studywarehouse_remove_newsletter', 20 );
function studywarehouse_remove_newsletter() {
wp_dequeue_style( 'td-plugin-newsletter' );
}
Preload Newspaper fonts
Preloading fonts will reduce the load time of the fonts on your website.
For a responsive version, you can add the following code to the theme’s functions.php
file under the path /wp-content/themes/Newspaper/functions.php
// Preload Newspaper fonts for responsive theme (main theme)
function dns_prefetch_responsive() {
echo "<link href='https://www.YOURDOMAIN.com/wp-content/themes/Newspaper/images/icons/newspaper.woff?19' rel='preload' as='font' type='font/woff' crossorigin>";
}
add_action( 'wp_head', 'dns_prefetch_responsive', 0 );
Add following code to mobile theme’s functions.php
file to preload Newspaper fonts.
You can find theme’s functions.php file under the path /wp-content/plugins/td-composer/mobile/functions.php
// Preload Newspaper fonts for mobile theme
function dns_prefetch_mobile() {
echo "<link href='https://www.YOURDOMAIN.com/wp-content/plugins/td-composer/mobile/images/icons/mobile-theme.woff?10' rel='preload' as='font' type='font/woff' crossorigin>";
}
add_action( 'wp_head', 'dns_prefetch_mobile', 0 );
Do not forget to replace www.YOURDOMAIN.com with your actual domain URL.
Preload fonts using WP Rocket plugin
WP Rocket has introduced fonts preload feature in the latest version. You can use this option to preload all fonts hosted on your server.
Preload Newspaper theme fonts using WP Rocket plugin
Preload Newspaper theme fonts using WP Rocket plugin
Conclusion
That’s it; you are done with the Newspaper theme optimization now check your website’s performance score at GTMetrix.com. I am sure you are much satisfied with the speed. If you are stuck somewhere to improve page loading speed or to optimize newspaper theme feel free to drop a comment below.
SEO Keywords
- Improve page loading speed
- Optimize Newspaper theme
- PageSpeed of Newspaper theme