Flash of unstyled content (FOUC) in Firefox only? Is FF slow renderer?

后端 未结 7 2002
[愿得一人]
[愿得一人] 2021-02-01 16:42

I\'m not seeing this issue in any other browser that I\'ve tested - IE, Chrome, Opera - but whenever I load a page from the server, I\'m seeing a flash of unstyled content befor

相关标签:
7条回答
  • 2021-02-01 17:17

    In my case the reason of FOUC in FF was the presence of iframe on page. If I removing iframe from markup then FOUC disappears.

    But I need iframe for my own hacking reasons so I changed this

    <iframe name="hidden-iframe" style="display: none;position:absolute;"></iframe>
    

    into this

    <script>
    
      document.addEventListener('DOMContentLoaded', ()=>{
        let nBody = document.querySelector('body')
        let nIframe = document.createElement('iframe');
        nIframe.setAttribute('name', "hidden-iframe");
        nIframe.style.display = 'none';
        nIframe.style.position = 'absolute';
        nBody.appendChild(nIframe);
      });
    </script>
    

    I've added this inline JS right in template just for readability: in my case this code runs once per page. I know that it's dirty hack, so you can add this code in separated JS-file.

    The problem was in Firefox Quantum v65.

    0 讨论(0)
提交回复
热议问题