In this article, I will show you how to add a Stylish Preload animation to your website using simple HTML, CSS, and Javascript code.
I will also show you how to set this animation to the homepage only using the "if condition" in the theme.
What is Loading Animation on a Website?
Loading animation is the first animation screen we see when we open a website. There are a lot of cool loading animations you can put on your website but putting a long/high graphics animation may increase your website load time and we don't want that. So this is a simple loading animation you can use on your website.
Loading animation is a way to tell your readers about your brand and blog, and with unique cool animation anybody can recognise your website is genuine and safe.
Why Loading animation is an important part of a website.
Reduce perceived wait time: Even with fast internet speeds, there will always be some delay in loading content. A loading animation can make the wait seem shorter by distracting the user and keeping them engaged. Studies have shown that perceived speed is often more important than actual speed, and a well-designed animation can significantly improve the user experience.
Provide feedback: When a user clicks on a button or link, they expect something to happen. A loading animation assures them that the action has been registered and the site is working behind the scenes. This helps to avoid confusion and frustration, especially for slower connections or complex interactions.
Enhance brand identity: Loading animations can be designed to reflect the website's brand or theme. This can be a subtle way to create a positive first impression and build brand recognition. For example, a playful animation might be suitable for a children's website, while a more sophisticated animation might be better for a financial institution.
It's important to note that loading animations should be used strategically. They should be lightweight, unobtrusive, and not overshadow the actual content of the website. If they are poorly designed or take too long, they can have the opposite effect and actually frustrate users.
The code Download Link is given below.
So, let's start. Steps to add Preload Animation
Step-1: Go to Blogger Dashboard and Create a Backup of your theme. Step-2: Now search for ]]></b:skin> tag or </style> tag and paste the CSS code just above it.
/* Preloader Animation In Blogger */
.preloader {
position: fixed;
width: 100%;
height: 100vh;
background: #0f0f0f;
left: 0;
top: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
transition: all 400ms;
z-index: 2000;
}
.preloader.hide {
opacity: 0;
pointer-events: none;
}
.preloader .preloader-text {
color: #838383;
text-transform: uppercase;
letter-spacing: 8px;
font-size: 15px;
}
.preloader .dots-container {
display: flex;
margin-bottom: 48px;
}
.preloader .dot {
background: red;
width: 20px;
height: 20px;
border-radius: 50%;
margin: 0 5px;
}
.preloader .dot.red {
background: #ef476f;
animation: bounce 1000ms infinite;
}
.preloader .dot.green {
background: #06d6a0;
animation: bounce 1000ms infinite;
animation-delay: 200ms;
}
.preloader .dot.yellow {
background: #ffd166;
animation: bounce 1000ms infinite;
animation-delay: 400ms;
}
@keyframes bounce {
50% {
transform: translateY(16px);
}
100% {
transform: translateY(0);
}
}
Step-3: Now search for </body> tag and paste the HTML and Javascript code above it.
<div class="preloader">
<div class="dots-container">
<div class="dot red"></div>
<div class="dot green"></div>
<div class="dot yellow"></div>
</div>
<div class="preloader-text">
Loading...
</div>
</div>
<script>
const preloader = document.querySelector(".preloader");
const preloaderDuration = 500;
const hidePreloader = () => {
setTimeout(() => {
preloader.classList.add("hide");
}, preloaderDuration);
}
window.addEventListener("load", hidePreloader);
</script>
Step-4: Now save your theme and the preload animation is added to your Blogger theme.
You can also add the preloading effect to the homepage only by adding the If condition wrapping both HTML and Javascript code.
<b:if cond= 'data:blog.url == "URL"'>
</b:if>
Loading animations are important for websites for several reasons, primarily related to user experience and engagement. Here’s why they matter:
In short, loading animations are essential for making websites feel responsive, engaging, and professional while improving the overall user experience.
As websites get bigger and more complex, loading animations becomes even more critical. Here's how they help in large-scale websites:
In conclusion, as a website grows in size and complexity, a well-designed loading animation can play a critical role in enhancing user experience, maintaining engagement, and providing valuable feedback during resource-heavy operations.