Skip to content Skip to sidebar Skip to footer

How To Show Website Preloader Only Once

I added a preloader to my website and the preloader animation will play every time the site is visited. I would like it to only play once per visit when going through the domain na

Solution 1:

Here is an example of how you might use sessionStorage to show the preloader once per visit per tab or window.

<script type="text/javascript">
$(document).ready(function() {
    $(window).load(function() {
        function Preloader() {
            var preloader = $ ('.loader');
            preloader.delay(1000) .fadeOut (500);
            var preloader = $('.preloader');
            preloader.delay (1500) .slideUp(500);
        }
        if ( ! sessionStorage.getItem( 'doNotShow' ) ) {
            sessionStorage.setItem( 'doNotShow', 'true' );
            Preloader();
        } else {
           $ ('.loader, .preloader').hide();
        }
    });
});
</script>

Post a Comment for "How To Show Website Preloader Only Once"