Home > OS >  Page loading div loads endless sometimes
Page loading div loads endless sometimes

Time:04-16

My pre page load script sometimes bugs out and is “loading” endless.

No console logs. Page is loaded correctly under the cover div.

It’s hard to explain any logic to moment it happens, looks like random thing.

custom.js:

$(function() {
    $(window).on("load", function(){
        $('#loader').css("display", "none", function() {
          $(this).remove();
        });
        $('html, body').css({
            'overflow': 'auto',
        })
    })
});

header.php:

<body <?php body_class('d-flex flex-column h-100 no-scroll');?>>

<div id="loader"><p>Loading</p></div>
    <?php wp_body_open(); ?>

    <header load", function(){
    $('#loader').css("display", "none", function() {
      $(this).remove();
    });
    $('html, body').css({
        'overflow': 'auto',
    })
})

CodePudding user response:

On load

$( window ).on("load", function() {
    ...trigger load
});

When document loaded

$( document ).ready(function() {
   ...remove loading
});
  • Related