WPBeginner

Beginner's Guide for WordPress

  • Blog
    • Beginners Guide
    • News
    • Opinion
    • Showcase
    • Themes
    • Tutorials
    • WordPress Plugins
  • Start Here
    • How to Start a Blog
    • Create a Website
    • Start an Online Store
    • Best Website Builder
    • Email Marketing
    • WordPress Hosting
    • Business Name Ideas
  • Deals
    • Bluehost Coupon
    • SiteGround Coupon
    • WP Engine Coupon
    • HostGator Coupon
    • Domain.com Coupon
    • Constant Contact
    • View All Deals »
  • Glossary
  • Videos
  • Products
X
☰
Beginner's Guide for WordPress / Start your WordPress Blog in minutes
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

WPBeginner» Blog» Plugins» How to Add a Preloader Animation to WordPress (Step by Step)

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

Last updated on December 11th, 2019 by Editorial Staff
76 Shares
Share
Tweet
Share
Pin
Free WordPress Video Tutorials on YouTube by WPBeginner
How to Add a Preloader Animation to WordPress (Step by Step)

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.

<div id="wptime-plugin-preloader"></div>

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 '<div id="wptime-plugin-preloader"></div>';
}
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.

76 Shares
Share
Tweet
Share
Pin
Popular on WPBeginner Right Now!
  • Checklist

    Checklist: 15 Things You MUST DO Before Changing WordPress Themes

  • How to Properly Move Your Blog from WordPress.com to WordPress.org

  • Google Analytics in WordPress

    How to Install Google Analytics in WordPress for Beginners

  • How to Fix the Error Establishing a Database Connection in WordPress

    How to Fix the Error Establishing a Database Connection in WordPress

About the Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Trusted by over 1.3 million readers worldwide.

The Ultimate WordPress Toolkit

2 Comments

Leave a Reply
  1. Vijay says:
    Nov 2, 2020 at 3:09 pm

    Hi, I am a non techie. Is preloader possible only with plugins or can acheive by code as well? I feel it will be good to minimize plugins as much as possible to avoid unncessary conflicts with theme updates or with others in future.

    Reply
    • WPBeginner Support says:
      Nov 3, 2020 at 10:23 am

      We do not have a beginner-friendly method for creating a preloader and manually creating the code would mean you are the author of a plugin added to your site rather than using a plugin someone has already created. You may want to take a look at our guide below:

      https://www.wpbeginner.com/opinion/how-many-wordpress-plugins-should-you-install-on-your-site

      Reply

Leave a Reply Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Over 1,320,000+ Readers

Get fresh content from WPBeginner

Featured WordPress Plugin
PushEngage
PushEngage
Increase your website traffic & revenue with push notifications. Learn More »
How to Start a Blog How to Start a Blog
I need help with ...
Starting a
Blog
WordPress
Performance
WordPress
Security
WordPress
SEO
WordPress
Errors
Building an
Online Store
Useful WordPress Guides
    • 7 Best WordPress Backup Plugins Compared (Pros and Cons)
    • How to Fix the Error Establishing a Database Connection in WordPress
    • Why You Need a CDN for your WordPress Blog? [Infographic]
    • 30 Legit Ways to Make Money Online Blogging with WordPress
    • Self Hosted WordPress.org vs. Free WordPress.com [Infograph]
    • Free Recording: WordPress Workshop for Beginners
    • 24 Must Have WordPress Plugins for Business Websites
    • How to Properly Move Your Blog from WordPress.com to WordPress.org
    • 5 Best Contact Form Plugins for WordPress Compared
    • Which is the Best WordPress Popup Plugin? (Comparison)
    • Best WooCommerce Hosting in 2021 (Comparison)
    • How to Fix the Internal Server Error in WordPress
    • How to Install WordPress - Complete WordPress Installation Tutorial
    • Why You Should Start Building an Email List Right Away
    • How to Properly Move WordPress to a New Domain Without Losing SEO
    • How to Choose the Best WordPress Hosting for Your Website
    • How to Choose the Best Blogging Platform (Comparison)
    • WordPress Tutorials - 200+ Step by Step WordPress Tutorials
    • 5 Best WordPress Ecommerce Plugins Compared
    • 5 Best WordPress Membership Plugins (Compared)
    • 7 Best Email Marketing Services for Small Business (2021)
    • How to Choose the Best Domain Registrar (Compared)
    • The Truth About Shared WordPress Web Hosting
    • When Do You Really Need Managed WordPress Hosting?
    • 5 Best Drag and Drop WordPress Page Builders Compared
    • How to Switch from Blogger to WordPress without Losing Google Rankings
    • How to Properly Switch From Wix to WordPress (Step by Step)
    • How to Properly Move from Weebly to WordPress (Step by Step)
    • Do You Really Need a VPS? Best WordPress VPS Hosting Compared
    • How to Properly Move from Squarespace to WordPress
    • How to Register a Domain Name (+ tip to get it for FREE)
    • HostGator Review - An Honest Look at Speed & Uptime (2021)
    • SiteGround Reviews from 4464 Users & Our Experts (2021)
    • Bluehost Review from Real Users + Performance Stats (2021)
    • How Much Does It Really Cost to Build a WordPress Website?
    • How to Create an Email Newsletter the RIGHT WAY (Step by Step)
    • Free Business Name Generator (A.I Powered)
    • How to Create a Free Business Email Address in 5 Minutes (Step by Step)
    • How to Install Google Analytics in WordPress for Beginners
    • How to Move WordPress to a New Host or Server With No Downtime
    • Why is WordPress Free? What are the Costs? What is the Catch?
    • How to Make a Website in 2021 – Step by Step Guide
Deals & Coupons (view all)
Beaver Builder Coupon Code
Beaver Builder Coupon
Get the best possible price on this easy drag-and-drop page builder plugin. From just $99 in 2020.
7Theme
7Theme Coupon
Get 10% OFF on Premium WordPress Themes by 7Theme.
Featured In
About WPBeginner®

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).

Join our team: We are Hiring!

Site Links
  • About Us
  • Contact Us
  • FTC Disclosure
  • Privacy Policy
  • Terms of Service
  • Free Blog Setup
  • Free Business Tools
  • Growth Fund
Our Sites
  • OptinMonster
  • MonsterInsights
  • WPForms
  • SeedProd
  • Nameboy
  • RafflePress
  • Smash Balloon
  • AIOSEO

Copyright © 2009 - 2021 WPBeginner LLC. All Rights Reserved. WPBeginner® is a registered trademark.

Managed by Awesome Motive | WordPress hosting by SiteGround | WordPress Security by Sucuri.