1. PROMO Upgrade to Pro Membership @ $99 / Lifetime & access all our 16+ premium Divi extensions: Divi Block, Carousel Toolkit, etc.LEARN MORE
Dismiss Notice
NEW Divi.Help Pro Carousel AI Toolkit - Magically turn your Divi design into carousel, simply by using our online toolkit. No plugins needed. Now it works with Divi 5 as well!Try our carousel AI toolkit
BEST Divi Block - A revolutionary drag & drop tool to easily mix & match 960+ premade blocks (Light & Dark) to kick start your Divi site design. Special module designs are included as well. Also newly added AI generator & color. Now it works with Divi 5 as well!
Learn More About Divi BlockFree Version ~ 340+ Free Blocks

Solved CLS With Mobile Menu in DIVI

Discussion in 'Support Forum' started by kiwikid, Dec 2, 2021.

  1. kiwikid

    kiwikid New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    Hi guys,

    I love your work...but when using Divi Blocks to make a header and mobile menu for Divi I end up with horrific CLS issues (mainly on Mobile views) ALl of the speed tests eg. GT and Insights, Litespeed all report around an average of CLS jumping from approx .007 with a standard Divi Global Header (most Divi premade ones) to .4 or .5 when implementing one of your ones? This is mostly on Mobile and Desktop stays in reasonable scores (.06 or so). Is there an answer/solution for this?, considering Google now places CLS pretty highly when ranking your website performance? What's the solution? Oh and yes...I have standard stuff above the fold...no animations, no backgrounds, and no complex layouts ( I leave this till further down the page) What are your thoughts on this? Thanks
     

    Attached Files:

    1. PRO MEMBER PERKS Divi Block Pro - 30+ premade custom header designs for you to choose from:View Demo
  2. Divi.Help

    Divi.Help Administrator
    Staff Member

    Normally if you set the below options, you should be able to get a decent CLS:

    upload_2021-12-3_13-38-45.png

    But I believe you already set it that way. After you set it, be sure to visit your page first to generate the static CSS file & clear your cache plugin & check the score again.
    **You may test it on a sample page & set Theme Builder to have custom header on that page. Once you created it, you may share your URL for us to take a look as well.

    Let me know how it goes.
     
  3. kiwikid

    kiwikid New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    Yea I don't know what's happening..might be something I am doing? It's a pain as your header design is exactly perfect for this website! works in well. I did what you recommended (although this was already set) created a test page with just text https://webglueux.com/cls/ I tested again and still the same. Thanks for having a look
     
    1. PRO MEMBER PERKS Divi Powerful Child Theme - Power up your Divi sites with tons of new functionalities & premade elements:Learn More
  4. Divi.Help

    Divi.Help Administrator
    Staff Member

    Since the above method doesn't work for you, thus I tried this code on your site & it seems to work just fine: https://www.markhendriksen.com/how-to-fix-divi-flashing-unstyled-content-on-page-load/

    Kindly check.
     
  5. kiwikid

    kiwikid New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    Yea it made the CLS improve a lot...But in the browser Firefox and Chrome the website jumps around when changing pages. Explorer, seems stable? I have 4 computers in the house so tried on them all and the same thing?
     
    1. PRO MEMBER PERKS Divi Block Pro - Premade gradient text design for your Divi site without using any plugins:View Demo
  6. Divi.Help

    Divi.Help Administrator
    Staff Member

    That's weird. I tested on Chrome & it seems to work just fine: https://recordit.co/9ekXrUY8c0

    The code basically just hide your page until your initial HTML document has been completely loaded. So it shouldn't be causing any jumping that are not seen previously.
     
  7. kiwikid

    kiwikid New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    yea it's a pain! Did you test it also before adding the code? I am going to start a new 'staging site' and just add a new header/mobile menu from Divi Blocks and see what happens.
     
    1. PRO MEMBER PERKS Beautifully crafted custom colored 'Digital Marketing' Divi layout for all Pro members:View Demo
  8. Divi.Help

    Divi.Help Administrator
    Staff Member

    You may temporarily remove the code at WP Admin > Divi > Theme Options > Integration > Header Code & see if the jumping is still there. Though it looks fine on my side.
     
  9. kiwikid

    kiwikid New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    Hi, ya here are the results of a clean Divi site with a default header and a couple of Divi templates to create pages and then after adding Divi.Block Header Menu.

    How is "The code basically just hide your page until your initial HTML document has been completely loaded." this a solution? if it doesn't actually address the root cause?

    No caching or any plugins on the site, as none of them would block the header loading anyway I guess? Might help defer a little?. This is the same CLS scores I am getting on the other site? Any thoughts? New clean site https://uiuxwebsitedesign.com.au/
     

    Attached Files:

    1. PRO MEMBER PERKS Custom Color Scheme + Premade Layouts - A perfect combination to boost productivity:Try Now
  10. Divi.Help

    Divi.Help Administrator
    Staff Member

    I did further testing on your site. I suspected that for your case it's due to the hidden desktop section on mobile.

    By default, Divi Block used inline CSS code in the header block to hide the unnecessary sections when custom mobile menu is present. But that seems to cause CLS on the mobile. Thus, I tried to set the desktop sections Visibility settings to be hidden on mobile & tablet, but that doesn't help either.

    Thus, I added this inline CSS at Divi Theme Options > Integration > Header Code, so that it will load the inline CSS earlier & hide those desktop sections earlier:
    Code:
    Log In or Sign Up to view this code.
    And it seems to lower your CLS.

    Thus, hidden desktop sections might be the culprit of the CLS.

    ===========

    As for the code from https://www.markhendriksen.com/how-to-fix-divi-flashing-unstyled-content-on-page-load/

    It helps in the way where once all the inline CSS code are loaded (including the hidden desktop section CSS), then only it shows the page, so that Pagespeed won't see any hidden desktop sections on mobile. That's why you will get low CLS.

    So basically, it's 2 different approach:
    1. Use the display none CSS in the head tag, so that it will run earlier.
    2. Use the JS to hide the page until all inline CSS are loaded.

    ===========

    Thought of another easier way is to move the code module (CSS For Hiding Other Mobile Menu) to the top of the header sections. After testing it, it did lower the CLS as well, but not as much as the CSS at Divi Theme Options > Integration > Header Code.
    **You may try this as well if you do not wish to add any code in the Header Code
     
  11. kiwikid

    kiwikid New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    Hi ya,
    Thank you for your time on this it is much appreciated. I will give these suggestions a go later tonight (have to work today! haha). Moving forward is there a way of only calling the mobile menu when required? instead of hiding the blocks in the header.

    Curious Question? (just trying to figure out how to correctly use your blocks)

    I get that your block system relies on <div> and <span> elements for stying as we change or put together our blocks?, but what if you then manually want to change a lot of the settings once you have imported them into your website? For instance: I want to change the text block for instance that has settings for spacing etc between the H1 and text...remove the H1/H2 text and also all the divi block text? (I like the headings separate so as I can maybe add transitions etc that only apply to the headings) does this break all the extra <div><span> tags?

    I wonder this as I have done this throughout my site and then noticed I ended up with or accidentally removed these <div> or span elements or ended up with these tags throughout my text etc that didn't seem relevant anymore and decided to manually remove them all from each imported module thus the 'class' for that module was also not needed?

    My question is: Are the blocks meant to be left as they are structured? Are they not to be used as say.....standard templates you then style yourself? cheers
     
    1. PRO MEMBER PERKS Divi Block Pro - Premade team carousel design for your Divi site without using any plugins:View Demo
  12. Divi.Help

    Divi.Help Administrator
    Staff Member

    Are you referring to hiding desktop menu section on mobile? Divi doesn't have such feature that completely remove the section on certain breakpoints. Divi only relies on the Visibility settings, where it will just use CSS to hide the section based on breakpoints.
    I believe this question only applies to our section heading, as you will notice that there's some empty div with CSS Class. That's meant for our Section Heading Style blocks.

    If you're not using our Section Heading Style blocks, then you can just ignore the empty div.

    If you need section heading style, you can always separate it into 2 different text modules, as the empty div are separated into top, middle & bottom:

    upload_2021-12-4_10-46-49.png

    Basically, it's either you:
    1. Create your own new section heading design
    2. Or just further customize the current Divi Block ones
    3. Or just stick with the default Divi Block ones

    And save the section heading row in library & re-use it as you like. It's all up to you.
     
  13. kiwikid

    kiwikid New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    Ok cool, thanks for taking the time to explain, was just trying to get my head around the structure for reference. Yeah, I'll have to come up with another solution for the mobile menu I guess as I cannot ignore the CLS considering Google has placed it highly for a website ranking factor. Love your designs though very clean and modern but the headers although excellent are a deal-breaker for me .4 is way too high. cheers anyway.
     
    1. PRO MEMBER PERKS Divi Login Customizer Plugin - Instantly beautify your Wordpress login page with 6 premade designs:Learn More
  14. kiwikid

    kiwikid New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    Oh it is most likely something to do with how I have structured the site...so Ill start again and see how I go, thank you so much for taking so much time to give me excellent support, Love your work! Thanks again your support has been amazing! cheers mate (as they say down under)
     
  15. kiwikid

    kiwikid New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    I think I solved it! Bloody forgot WordPress lazy loads natively now which was causing most of the CLS, used wp rockets lazy load which turns off WordPress native lazyloading and excluded all the images above the fold on each page! worked a charm and stopped the jumping! Sorry if I wasted your time. It only occurred to me once I remembered about the new updates WordPress introduced recently.
     
    1. PRO MEMBER PERKS Beautifully crafted custom colored 'Freelancer' Divi layout for all Pro members:View Demo
  16. Divi.Help

    Divi.Help Administrator
    Staff Member

    Glad you have it all works out.

    As per what I tested earlier, the below CSS code that I added in Divi > Theme Options > Integration > Header Code did lower your CLS to around 0.031:
    Code:
    Log In or Sign Up to view this code.
    ========

    Anyway, it would be great if you could drop us a review here: https://divi.help/forums/customer-testimonials.176/
    **It's greatly appreciated.