Elevate Your Shopify Store's UX: A Step-by-Step Guide to Custom Loading Screens
Hey there, fellow store owners! As someone who spends a lot of time diving into the Shopify community forums, I often see common questions pop up that really highlight areas where we can all make our stores better. One topic that caught my eye recently was about adding a 'loading mark' or, as we often call it, a preloader or loading screen to a Shopify store. It's a fantastic idea for improving user experience and giving your brand a polished touch.
Our friend @BY2025 recently kicked off a thread asking how to display a logo image while their page loads, specifically wanting a plain background with the logo centered, fading in and out. They were using the Madrid 1.4.0 theme, which is a great starting point for custom work. Luckily, another community member, @shopplaza_team, jumped in with a super detailed, step-by-step solution that's adaptable for almost any modern Shopify theme, including Madrid!
Let's break down this excellent community-shared solution to get a custom, branded loading screen up and running on your Shopify store.
Why a Loading Screen?
Before we dive into the 'how,' let's quickly touch on 'why.' A loading screen isn't just a fancy animation; it serves several purposes:
- Enhances User Experience: It provides visual feedback that something is happening, reducing perceived loading times and frustration.
- Branding: It's another opportunity to showcase your logo and reinforce your brand identity right from the moment a user lands on your site.
- Professionalism: A well-implemented loading screen makes your site feel more polished and professional.
Implementing Your Custom Loading Screen: Step-by-Step
The solution provided by @shopplaza_team is incredibly thorough, involving a bit of Liquid, CSS, and JavaScript. Don't worry if that sounds intimidating; we'll walk through it together. Remember, always make a duplicate of your theme before making any code changes!
Step 1: Create Your Loading Screen Snippet
First, we need to create the HTML structure for our loading screen. This will live in a new Liquid snippet.
- In your Shopify admin, navigate to Online Store > Themes.
- Find your current theme (or the duplicate you made) and click Actions > Edit code.
- Under the
Snippetsdirectory, click Add a new snippet. - Name it
loading-screen.liquidand click Done. - Paste the following code into the new file. Remember to replace the placeholder SVG with your actual logo, or better yet, an
tag pointing to your logo asset!
Expert Tip: While the SVG is cool, most stores will want to use their actual logo image. To do this, replace the block with something like: . Make sure your logo image is uploaded to your theme's Assets section.
Step 2: Render the Loading Screen
Now that we have our snippet, we need to tell Shopify to include it in our theme's layout.
- In the
layoutdirectory, opentheme.liquid. - Locate the
tag. Immediately after it, add the following line:
...
{% render 'loading-screen' %}
...
This ensures our loading screen HTML is present on every page load.
Step 3: Style Your Loading Screen with CSS
Next, we'll add the CSS to make our loading screen look good, center the logo, and create the fade-out effect. @shopplaza_team suggested adding this to assets/base.css, which is a common place for global styles.
- In the
assetsdirectory, openbase.css(or your theme's main CSS file, liketheme.cssormain.css). - Scroll to the bottom of the file and paste this CSS:
...
/* Loading Screen Styles */
.loading-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.95);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
transition: opacity 0.5s ease-out;
}
.loading-overlay.fade-out {
opacity: 0;
pointer-events: none;
}
.loading-logo {
animation: fadeInOut 2s ease-in-out infinite;
}
/* Define the fade in/out animation for the logo */
@keyframes fadeInOut {
0% { opacity: 0; }
50% { opacity: 1; }
100% { opacity: 0; }
}
I've added the @keyframes for fadeInOut, which was implicitly referenced. This CSS sets up a full-screen overlay, centers its content (your logo), gives it a semi-transparent white background, and prepares it for a smooth fade-out. The .loading-logo class makes your logo fade in and out repeatedly while the page is loading.
Step 4: Create the JavaScript for Hiding the Screen
Finally, we need some JavaScript to detect when the page has fully loaded and then hide our loading screen.
- In the
assetsdirectory, click Add a new asset. - Choose to create a blank file and name it
loading-screen.js. - Paste the following JavaScript code into the new file:
window.addEventListener('load', function() {
const loadingScreen = document.getElementById('loading-screen');
if (loadingScreen) {
loadingScreen.classList.add('fade-out');
setTimeout(function() {
loadingScreen.style.display = 'none';
}, 500); // This matches the CSS transition duration
}
});
This script waits for the entire page (images, scripts, everything) to load. Once it does, it adds the fade-out class to our loading screen, which triggers the CSS transition. After the transition completes (0.5 seconds), it completely removes the loading screen from display.
Step 5: Link Your JavaScript File
The last piece of the puzzle is to ensure our new JavaScript file is loaded by the browser. @shopplaza_team suggested adding it to snippets/scripts.liquid, which is a great practice for keeping your script includes organized.
- In the
snippetsdirectory, openscripts.liquid(if it doesn't exist, you might need to find where your theme includes its main JavaScript files, often intheme.liquidnear the closingtag). - Add the following line to include your new script:
...
...
The defer attribute is important here; it tells the browser to execute the script after the HTML is parsed, but before the DOMContentLoaded event, which is usually a good balance for performance.
After all these steps, you should see something similar to what @shopplaza_team shared:

And here's the image BY2025 shared, indicating their desired look:

Final Thoughts and Customization
This solution is robust and adaptable. You can easily:
- Change the background color: Adjust
background: rgba(255, 255, 255, 0.95);in.loading-overlayto any color or transparency you prefer. - Customize the logo animation: Tweak the
@keyframes fadeInOutto change the speed, style, or even add different animations. - Use an actual image: As mentioned, replace the SVG in
loading-screen.liquidwith antag pointing to your logo.
While the original question mentioned the Madrid 1.4.0 theme, the beauty of this solution is its general applicability. Modern Shopify themes, including Dawn and its derivatives like Horizon, follow similar Liquid file structures, so these steps should work well. Just be mindful of where your theme typically stores its global CSS and JavaScript files.
Remember to test thoroughly after implementing any code changes. A custom loading screen is a small detail that can make a big difference in how your customers perceive your brand. Big thanks to @shopplaza_team for sharing such a comprehensive guide with the community!