Hello @Rakesh_chougale , First, I would like you to share the website url for further analysis of site performance. As you have already applied lazy loading and preloading none, but still the issue is not resolved as there might be you have not applied on the elements effectively.
Below are some more advanced practices you can follow to make the change -
Lazy Loading the Animation on Scroll
As you wanted, your animated background image should be loaded first. I recommend that you either try to compress it or apply lazy loading to fix the LCP issues of your site. Here’s a basic example of how you could implement this:
window.addEventListener('scroll', function() {
const heroSection = document.querySelector('.hero');
const rect = heroSection.getBoundingClientRect();
if (rect.top <= window.innerHeight) {
document.querySelector('.hero-background').classList.add('active');
}
});
Background Animation and Preload Impact
Even though you’re using preload=“none” and loading=“lazy”, some browsers may still fetch the asset as part of the initial page load if it’s referenced directly or if it’s preloaded under certain conditions (e.g., CSS background-image or hidden elements). The preview image could also be included in the initial asset fetch depending on the resource type.
So I recommend you try the conditional visibility settings in combination with custom scripts to ensure that the asset isn’t fetched at all on mobile, rather than just hidden.
For example -
// Wait for the document to load before running the script
document.addEventListener("DOMContentLoaded", function() {
const heroBackground = document.querySelector('.hero-background');
const heroSection = document.querySelector('.hero-section');
// Function to check viewport width and show/hide elements accordingly
function checkViewportSize() {
if (window.innerWidth >= 1024) { // Desktop view
heroBackground.style.display = 'block';
} else { // Mobile view
heroBackground.style.display = 'none';
}
}
checkViewportSize();
// Add an event listener to check when the window is resized
window.addEventListener('resize', checkViewportSize);
});
Alternatively, if you do not want to go deep down into developer things, I recommend you try website speedy - a webflow app that performs the optimization automatically by handling JS, CSS on its own. It comes with a 14-day free trial.
( Disclaimer: We are the developers of this app and are happy to assist you with any problem that may arise.)