Tagged: fullscreen slider, loading speed, pagespeed, visibility
-
AuthorPosts
-
November 4, 2025 at 6:41 pm #1490944
I use four Fullscreen Sliders on my main home page—one for each of the responsive width visibility options. In other words, one Slider shows for viewers whose screen is under 479px, and the other three Sliders do not show. If the person’s screen is above 990 px, a different Fullscreen Slider shows and the other three are hidden, and so on for the other two responsive width categories.
This is very helpful for customizing the look of the website to the person’s device, but it seems like all FOUR Fullscreen Sliders and their content are being loaded by the browser—even if only one is visible—and this is resulting in my PageSpeed ranking being adversely affected and the site being loaded more slowly than I would like.
My goal is to have a good PageSpeed rank and have my site pages load quickly. Can you help me make it so that only the assets needed for any particular user’s display are loaded without having the other content loaded in the background (since it’s not needed for their specific display width)?
Thank you.
November 4, 2025 at 7:54 pm #1490953maybe this gives you some hints how it could be obtained: https://kriesi.at/support/topic/the-website-loads-invisible-elements/#post-1490800
November 5, 2025 at 7:16 pm #1490985Hi @Guenni007,
Thank you for the suggestion. I looked through that thread, but it seems to help solve loading/hiding video within an avia framework element (e.g., color section), but not the loading of the avia element itself (e.g., fullscreen slider) and all of its image content.
Am I missing something?
Ideally, the display of the user would be determined early in the page loading process and, based on the result, would only load one of the fullscreen sliders I have on the home page, and would not load (or show) any of the others.
November 10, 2025 at 3:22 am #1491086Hi,
Thank you for the inquiry.
You can try this script in the functions.php file to deactivate slides that are not visible on the current screen size.
— https://pastebin.com/RKdaXj6s
add_action('wp_footer', function() { ?> <script> document.addEventListener("DOMContentLoaded", function() { const sliders = document.querySelectorAll(".avia-slideshow"); function activateVisibleSlider() { sliders.forEach(slider => { const isVisible = slider.offsetParent !== null; const slides = slider.querySelectorAll("li[data-img-url]"); slides.forEach(slide => { const bgUrl = slide.getAttribute("data-img-url"); if (isVisible) { slide.style.backgroundImage = <code>url("${bgUrl}")</code>; } else { slide.style.backgroundImage = "none"; } }); }); } activateVisibleSlider(); let resizeTimer; window.addEventListener("resize", () => { clearTimeout(resizeTimer); resizeTimer = setTimeout(activateVisibleSlider, 200); }); }); </script> <?php }, 999);Best regards,
IsmaelNovember 12, 2025 at 10:12 pm #1491256Hi @Ismael,
I appreciate the code solution you’ve provided. I’ve implemented it on the site (pasted at the end of the functions.php file), but I was wondering if there was some way to test it to know it’s working as intended?
Thanks!
November 13, 2025 at 4:55 am #1491272Hi,
Thank you for the update.
Looks like the slide images are still loading on all screen sizes. We may need to log in to the site to properly test the modification. Please provide the login details in the private field.
Best regards,
IsmaelNovember 18, 2025 at 9:39 pm #1491485This reply has been marked as private.November 19, 2025 at 6:13 am #1491493Hi,
Thank you for the info.
Looks like the script is not working as intended so we removed it. Unfortunately, we didn’t find any other solution to prevent the slides’ background images from loading when the slider is not visible. You may need to remove the other sliders and rely on the responsive images if you’re using the Fullwidth Easy Slider, or manually apply different background images to the slides for different screen sizes using css. Example:
/* mobile */ @media (max-width: 767px) { .avia-fullscreen-slider .avia-slideshow > ul > li:nth-child(1) { background-image: url("/path/to/slide1-mobile.jpg") !important; } .avia-fullscreen-slider .avia-slideshow > ul > li:nth-child(2) { background-image: url("/path/to/slide2-mobile.jpg") !important; } .avia-fullscreen-slider .avia-slideshow > ul > li:nth-child(3) { background-image: url("/path/to/slide3-mobile.jpg") !important; } } /* tablet */ @media (min-width: 768px) and (max-width: 1023px) { .avia-fullscreen-slider .avia-slideshow > ul > li:nth-child(1) { background-image: url("/path/to/slide1-tablet.jpg") !important; } .avia-fullscreen-slider .avia-slideshow > ul > li:nth-child(2) { background-image: url("/path/to/slide2-tablet.jpg") !important; } .avia-fullscreen-slider .avia-slideshow > ul > li:nth-child(3) { background-image: url("/path/to/slide3-tablet.jpg") !important; } }Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.
