How to write such a function, which tracked the page loading time and if the loading goes, for example more than 10 seconds, hide the preloader and show the page as it was at that moment.
jQuery(window).load(function(){ setTimeout(function () { var preloader = jQuery('.preloader_wrap'); var anim_preload = jQuery('.preloader'); anim_preload.fadeOut(500); preloader.delay(500).fadeOut('slow'); },2500); }); .preloader_wrap{ position: relative; width: 400px; height: 400px; background-color: pink; } .preloader{ position: absolute; margin: auto; width: 222px; height: 222px; border-radius: 100%; border: 2px solid transparent; border-top-color: red; animation: spin 1s infinite linear; z-index: 1; } @keyframes spin { from{ transform: rotate(0deg); }to{ transform: rotate(-360deg); } } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="preloader_wrap"> <div class="preloader"></div> </div> <h1>Content</h1>