Last active
December 2, 2023 18:34
-
-
Save softiconic/afc50628def8b563c0faae1c7a89da95 to your computer and use it in GitHub Desktop.
Smart Preloader for WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('load', function(event) { | |
fadeAway(); | |
function fadeAway() { | |
var delay = 1000; // Adjust the delay in milliseconds as needed | |
var duration = 500; // Adjust the duration in milliseconds as needed | |
// Check if jQuery is defined and if not, load it | |
if (typeof jQuery === 'undefined') { | |
var script = document.createElement('script'); | |
script.src = 'https://code.jquery.com/jquery-3.6.0.min.js'; // You can change the jQuery version as needed | |
script.onload = function() { | |
jQueryLoaded(); | |
}; | |
document.head.appendChild(script); | |
} else { | |
jQueryLoaded(); | |
} | |
function jQueryLoaded() { | |
setTimeout(function() { | |
jQuery('.smart-page-loader').fadeOut(duration, function() { | |
jQuery('body:not(".elementor-editor-active")').removeClass('wp-smart-body'); | |
}); | |
}, delay); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment