window._wpemojiSettings = {"baseUrl":"https:\/\/s.w.org\/images\/core\/emoji\/12.0.0-1\/72x72\/","ext":".png","svgUrl":"https:\/\/s.w.org\/images\/core\/emoji\/12.0.0-1\/svg\/","svgExt":".svg","source":{"concatemoji":"https:\/\/wpbrilliance.com\/wp-includes\/js\/wp-emoji-release.min.js?ver=5.4.1"}}; /*! This file is auto-generated */ !function(e,a,t){var r,n,o,i,p=a.createElement("canvas"),s=p.getContext&&p.getContext("2d");function c(e,t){var a=String.fromCharCode;s.clearRect(0,0,p.width,p.height),s.fillText(a.apply(this,e),0,0);var r=p.toDataURL();return s.clearRect(0,0,p.width,p.height),s.fillText(a.apply(this,t),0,0),r===p.toDataURL()}function l(e){if(!s||!s.fillText)return!1;switch(s.textBaseline="top",s.font="600 32px Arial",e){case"flag":return!c([127987,65039,8205,9895,65039],[127987,65039,8203,9895,65039])&&(!c([55356,56826,55356,56819],[55356,56826,8203,55356,56819])&&!c([55356,57332,56128,56423,56128,56418,56128,56421,56128,56430,56128,56423,56128,56447],[55356,57332,8203,56128,56423,8203,56128,56418,8203,56128,56421,8203,56128,56430,8203,56128,56423,8203,56128,56447]));case"emoji":return!c([55357,56424,55356,57342,8205,55358,56605,8205,55357,56424,55356,57340],[55357,56424,55356,57342,8203,55358,56605,8203,55357,56424,55356,57340])}return!1}function d(e){var t=a.createElement("script");t.src=e,t.defer=t.type="text/javascript",a.getElementsByTagName("head")[0].appendChild(t)}for(i=Array("flag","emoji"),t.supports={everything:!0,everythingExceptFlag:!0},o=0;o
Dec 11, 2019
29 Views
0

How to Add a Preloader Animation to WordPress (Step by Step)

Written by

Do you want to add a preloader to your WordPress site? A preloader is an animation indicating the progress of a page load in the background. Preloaders assure users that the website is working on loading the page. This can help improve user experience and reduce overall bounce rate. In this article, we’ll show you how to easily add a preloader to WordPress. What is a Preloader and When You Should Use it? A preloader is an animation or status message indicating the progress of page load in the background. Normally when you visit a website, your browser starts downloading different parts of…

Do you want to add a preloader to your WordPress site? A preloader is an animation indicating the progress of a page load in the background.

Preloaders assure users that the website is working on loading the page. This can help improve user experience and reduce overall bounce rate.

In this article, we’ll show you how to easily add a preloader to WordPress.

Adding a preloader to your WordPress website

What is a Preloader and When You Should Use it?

A preloader is an animation or status message indicating the progress of page load in the background.

Normally when you visit a website, your browser starts downloading different parts of the content. Some parts of the website load faster (i.e. text, HTML code, CSS) whereas others load way slower (i.e images and videos).

If most of your content is text with very few images and videos, then you don’t really need to add a preloader to your website. Instead, you should focus on improving website speed and performance for faster page loads.

On the other hand, if most of your content is images, photographs, and video embeds, then your users need to wait a while before they can actually see all the content.

During these partial downloads, your website may feel slow. Sometimes users may even think that it is broken. Adding a preloader, fills this gap and shows the user a progress indicator during the page load.

You can see a live example of a preloader by clicking on the Preview button while writing a blog post in WordPress.

WordPress will open a live preview of your blog post in a new window, and it will display a preloader before it actually shows the live preview.

WordPress post preview preloader

That being said, let’s take a look at how you can easily add a preloader to your WordPress website.

Method 1. Adding a Preloader in WordPress using WP Smart Preloader

This method is recommended because it is easier to implement and does not require any changes to your WordPress theme.

First thing you need to do is install and activate the WP Smart Preloader plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit Settings » WP Smart Preloader page to configure plugin settings.

WP Smart Preloader settings

First, you need to choose a preloader style or page load animation. The plugin comes with six built-in animations to choose from. You can also upload your own custom HTML and CSS to create a custom preloader.

After that, you can make the preloader appear only on the homepage by checking the ‘Show only on Home Page’ option.

Next, you need to scroll down to the ‘Duration to show Loader’ section. You need to specify the duration for the preloader. The default option is 1500 milliseconds (1.5 seconds) which should work for most sites, but you can change that if you want.

Set preloader duration and fade out

You can also set the time loader takes to completely fade out. The default option is 2500 seconds or 2.5 seconds.

Finally, don’t forget to click on the ‘Save changes’ button to store your settings.

You can now visit your website to see the preloader in action.

WP Smart Preloader Preview

Method 2. Adding a Preloader in WordPress using Preloader Plugin

This method is flexible but requires additional steps to properly implement it on your WordPress site.

The first thing you need to do is install and activate the Preloader plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit the Plugins » Preloader page to configure plugin settings.

Preloader settings

First, you need to enter the Hex code for the background color you want to use for the loading screen. The default option is #FFFFFF (white). You can use an online color picker tool to find the HEX code for the color you want to use.

Next, you need to provide the URL of the preloader image you want to use. The plugin comes with a default animation image.

If you want to use other animation, then you’ll find a link to download an animated preloader image from a third-party website. You can then upload that image to your wp-content folder and paste the URL here.

Next, you need to choose where you want to display the preloader.

Select preloader locations

You can choose to display it on all pages of your website, or you can select a specific section.

Finally, you will see the instruction to add the following code to your WordPress theme’s header.php file.

Before you leave the page, don’t forget to click on the ‘Save changes’ button to store your settings.

We don’t recommend adding code to your WordPress theme because it will get wiped off when you update the theme.

If you are using a child theme, then it is ok to add the code to your child theme’s header.php file.

An even better solution would be to add this code using a separate Code Snippets plugin, or in a site-specific plugin.

Here’s the code you’d need to add:

function wpb_add_preloader() {
echo '
'; } add_action( 'wp_body_open', 'wpb_add_preloader' );

Note: this method of adding code will only work on WordPress themes that are compatible with the wp_body_open() function added in WordPress 5.2.

This method of adding the code makes sure that your code stays there even if you update the theme.

Once you have added the code, you can visit your website to see the preloader in action.

Preloader preview

We hope this article helped you learn how to easily add a Preloader to your WordPress site. You may also want to see our list of the most useful WordPress tips, tricks, and hacks for more cool ideas.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Add a Preloader Animation to WordPress (Step by Step) appeared first on WPBeginner.

Article Categories:
WordPress Plugins

Leave a Reply

Your email address will not be published. Required fields are marked *

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc a odio nec justo rutrum faucibus.
$20
Buy Now