Hide page until everything is loaded Advanced

前端 未结 8 1632
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 04:10

I have a webpage which heavily makes use of jQuery.

My goal is to only show the page when everything is ready.

With that I want to avoid showing the annoying

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-13 04:32

    Here is a jQuery solution for those looking:

    Hide the body with css then show it after the page is loaded:

    CSS:

    html { visibility:hidden; }
    

    JavaScript

    $(document).ready(function() {
      document.getElementsByTagName("html")[0].style.visibility = "visible";
    });
    

    The page will go from blank to showing all content when the page is loaded, no flash of content, no watching images load etc.

提交回复
热议问题