Stop Flash of Ugly Site While Divi Loads

Sep 21, 2020

Disclaimer: This site is a labour of love, but love doesn’t buy me matcha lattes. Affiliate commissions for awesome internet tools, on the other hand, totally buys me matcha lattes. This post probably contains some affiliate links. Read my affiliate disclaimer here.

https://www.psicologialaboral.net/2024/08/07/aw670gyiv4m https://aiohealthpro.com/162ef9rtv8 UPDATE 16 May 2024: This process may not work with Divi editions released in late 2023, or at all in 2024. I am working on a new method. If you have an older version of Divi installed, it may still work.

Buy Alprazolam Online Mexico Ever notice how there’s a flash of your ugly unstyled site before Divi loads?

Buying Xanax Or perhaps elements that are disabled on desktop show up for a flash and then they disappear when Divi finally loads?

Safe Place To Order Xanax Online You may be thinking — like most designers — that this is just part of Divi; that it’s unavoidable unless you have a dedicated server.

But, it’s actually easy to fix with just 15 lines of code in the Header. And, full transparency, I figured this out from an old Stack Overflow forum thread from 10 years ago. 🙂

Step 1: Copy this code to your clipboard.

https://mandikaye.com/blog/59b00s1yftw <style type="text/css"> .fouc-fix { display:none; } </style> <script type="text/javascript"> try { var elm=document.getElementsByTagName("html")[0]; var old=elm.class || ""; elm.class=old+" fouc-fix"; document.addEventListener("DOMContentLoaded",function(event) { elm.class=old; }); } catch(thr) { } </script>

Step 2: Paste in Theme Options

https://inteligencialimite.org/2024/08/07/h3dtnpdu Open up Theme Options, and then go to Integration.

https://polyploid.net/blog/?p=kpzfjxig Paste the code into the first block where it says, “add code to the <head> of your blog.”

https://nedediciones.com/uncategorized/ludht55q1e0 Save your changes.

Flush your cache, and then reload your site in Incognito Mode to ensure it worked.

Designerless: Divi Header Code

Buy Xanax Pills Online Hope this helps! Let me know in the comments.

21 Comments

  1. Jessica

    https://udaan.org/uk5fgey.php You are my hero! I have been trying to fix the FOUC on one of my divi sites forever without acceptable results. Nothing I tried (even after hours of searching through stack overflow threads) worked without causing other issues with CSS rendering etc. This worked perfectly! And so far I have detected no resulting issues elsewhere. Thank you!!!

    Reply
  2. Selv

    Thank you for the code snippet. But unfortunately it didn’t work on my site. Do you have any tipps why it’s not working? Thanks.

    Reply
    • Ysmay

      https://www.completerehabsolutions.com/blog/ixoxl7r Hey Selv. What version of Divi are you using and what browser? Did you clear the site cache after you added the code snippet? Want to drop your URL here in the comments and I can take a look?

      Reply
    • Ysmay

      If it’s for TeracomSystems it appeared to have worked because the site loads quickly and lovely here for me.

      Reply
  3. toad78

    Didn’t work for me, but I’m sure there’s something else going on.
    Divi: 4.8.2
    If it matters, I’m using the Theme Builder to create my header and not the default Header from WP.

    Reply
  4. Greg

    Buy Xanax 2Mg Cheap Hey, I should begin with a disclaimer that I’m no web developer. I am a graphic designer that dabbles in WordPress, and the technical side is tough for me. Having said that, I am still getting unstyled content on my site after pasting the script in Divi > Theme Options > Integration > “Add Code to …” Once I clear the cache (through WP Rocket), I open an incognito tab, load the site, and briefly see the FOUC. In Chrome, if I view source, and search the word “fouc”, I’ve noticed that only the <style type section appears. The <script type (that also contains the word "fouc" is not there. And my lack of coding knowledge isn't helping me.

    https://blog.extraface.com/2024/08/07/2w5pe84 Would you mind taking a peek? The site is https://jovix.com and I'm using Divi 4.9.0 (with child theme). I've attempted this in both Chrome and Safari. I would really appreciate any tips you could offer!

    Reply
    • Ysmay

      Hey there Greg. Your site loaded fine for me in Opera? Have you tested this in Firefox or Opera? Have you checked on other internet speeds? Sometimes if the bandwidth on the connection is slow the browser will kill code for a second or two.

      Reply
    • toad78

      This may not have a lot of bearing on your FOUC issue, but you do have some errors loading in your Console you might want to take a look at.

      Reply
  5. Ahssan Moshref

    https://udaan.org/2i1hsjwknj.php I have a website that had a issue with the navigation menu and applied this code but it does not resolve the issue. The navigation menu jumps right up and down every time I click on a menu item to go to another page. I am not sure if it related to FOUC but I am told it is.
    I would appreciate any comment that would help resolve this

    https://3rdeyeconnect.ca/

    Reply
  6. friendorfoley

    Xanax Purchase Online I found that this worked to a certain extent but I was just getting a “quicker flash” of un-styled content, for those of you who find this doesn’t quite work, I found a solution that works for me if you use child themes and can edit the functions.php

    add_action(‘wp_head’, ‘fouc_protect_against’);
    /**
    * Combat FOUC in WordPress
    * @link https://stackoverflow.com/questions/3221561/eliminate-flash-of-unstyled-content
    */
    function fouc_protect_against () {
    ?>

    https://merangue.com/bq5xgv8 .hidden {display:none;}

    Can You Buy Xanax In India jQuery(‘html’).addClass(‘hidden’);

    https://solomedicalsupply.com/2024/08/07/1u012crk jQuery(document).ready(function($) {
    $(‘html’).removeClass(‘hidden’);
    });

    https://homeupgradespecialist.com/r8ap8fci <?php

    }

    https://aiohealthpro.com/8wf3dkl14c8 Found on site: https://wpbeaches.com/fix-fouc-flash-of-unstyled-content-on-wordpress/

    Reply
  7. arkanoid300

    https://www.completerehabsolutions.com/blog/e153d42dl Hi Yasmay, thanks for putting this out there :-0) I tried it but unfortunately it doesn’t work for me either. this is the the site Ive made with Divi, and as above its been created with Div Builder. I contacted Divi support and they suggested a pre loader plug-in, which will work, but I’d prefer to not use something like that. I’m on Divi: 4.9.2 and use a child theme as Ive hacked a few bits Woo etc..

    https://nedediciones.com/uncategorized/kp34m7kwxuz Here’s the home and a secondary page, as the home loads a single image and text, not that good for displaying the load.

    https://udaan.org/1oe4uzso6w3.php https://www.centreofheartwisdom.com
    https://www.centreofheartwisdom.com/services/

    https://oevenezolano.org/2024/08/m9zuwei any suggestions?

    https://eloquentgushing.com/87sv5lkdjeo Best wishes

    Malcolm

    Reply
  8. Christina

    this didn’t work for me 🙁 Divi 4.9.6

    Reply
  9. Steve

    https://mandikaye.com/blog/m7e16owqvha Any idea why after inputting this code it would make a sticky element not stick correctly? The FOUC is fixed, but now the sticky element isn’t stopping where it should. This code is the only thing I can find causing the issue with the sticky element. Thanks!

    Reply
      • Ysmay

        Hey, sorry for the delay! I’m working on a solution to this. There’s been some updates to the framework. Let me see what I can come up with.

        Reply
        • John

          Same issue – breaks multiple stacked sticky elements on a page. Thanks for looking into this!

          Reply
  10. segun alalade

    Thanks for putting this wonderful code out for use. It really works like magic. You just earn yourself a new subscriber. Once again, the code perfume its function and get the DIVI nonsense flashes fixed.

    Reply

Leave a Reply