Conflict with Divi
-
Hi, this is gonna be a loooooong issue, so please bear with me.
With Reddit i found an Issue that causes my mobile Menu in Divi to break. At first glance, it seemed, that Complianz is causing the issue, but upon further investigation, it seems that overall LiteSpeed is causing that issue. Here’s the first part regarding Complianz and what i’ve done so far.
Hello,
i ran into an absolutely nervebreaking issue where the mobile Menu in my Divi Theme didn’t work anymore and took to Twitter. And one comment solved the issue, which is caused by Complianz. This should maybe be fixed in an future Update. First, here’s the Comment:
The JavaScript error I see is “ReferenceError: et_pb_custom is not defined”, triggered in Divi’s “scripts.min.js” file.
I might be wrong but it looks to me like the Complianz plugin is delaying loading of both an inline script (which defines the et_pb_custom variable) and scripts.min.js (which uses it). Presumably, this is done so that the scripts aren’t loaded until the user has accepted the Complianz terms.
Depending on how the Complianz plugin then runs these scripts, possibly this is affecting the execution order and making the et_pb_custom variable unavailable to the script. You may not be seeing this if you are logged in as admin, as presumably Complianz won’t run the same in that case.
You could test this by a) logging out or using an incognito window to hopefully let you see the issue, and b) temporarily disabling complianz (also clear lightspeed’s cache when you do) to hopefully then resolve it.
If it is Complianz that’s responsible then you may be able to solve it by excluding the inline script within the Complianz settings – I’m assuming there’s a way to do that. The inline script has the ID “divi-custom-script-js-extra”. It just sets some config variables; I don’t believe it includes user data or makes external calls), so I’d think it would be safe to exclude, from a privacy compliance point of view, but please check that against your own requirements.
[Link]
So, here’s what i did.
I used the following Snippet:
function cmplz_add_custom_whitelisted_script_tags( $whitelisted_script_tags ) { $whitelisted_script_tags[] = 'divi-custom-script-js-extra'; //'string from inline script or source that should be whitelisted' return $whitelisted_script_tags; } add_filter( 'cmplz_whitelisted_script_tags', 'cmplz_add_custom_whitelisted_script_tags', 10, 1 );
And added the following scripts to the whitelist (i use my own CDN):
https://gooloode.b-cdn.net/wp-content/themes/Divi/js/scripts.min.js
https://gooloode.b-cdn.net/wp-content/themes/Divi/js/scripts.min.js?ver=4.23.1
This was the reply from Complianz:
Hi @gooloode,
If we assume that Complianz causes this behavior, then I would expect it to be resolved when Complianz is no longer ‘blocking’ any scripts on the page (i.e. when Safe Mode is enabled).
But if I do this for your website by visiting it with the parameter??cmplz_safe_mode=true?appended to the URL:?
https://www.example.de/?cmplz_safe_mode=true
, it seems that the exact same error still appears; even though Complianz is no longer blocking the script.So this i was has come afterwards:
Hey u/nkoffiziell, sorry to you and Complianz for the misdiagnosis.
However, it seems the Complianz exclusion you’ve made has revealed a new JavaScript error “Uncaught SyntaxError: Invalid or unexpected token ” which is occurring in the inline script, in the declaration of et_pb_custom itself (and triggering the original error).
Simplifying, it looks like this:
var et_pb_custom = {... ,"et_frontend_nonce":"
<!– Block cached by LiteSpeed Cache 5.7.0.1 on 2023-11-22 17:34:45 –>”,”…};
Normally et_frontend_nonce would be a value such as “cd3112a755”, but it looks like it is being replaced by a comment from, presumably, LiteSpeed Cache. In particular, the newline before the comment seems to be breaking the declaration, leaving et_pb_custom undefined. I tried manually editing the comment / newline out of the page and once I did, the menu started working for me.
I’d suggest temporarily disabling LiteSpeed Cache to test this. If the menu works with LiteSpeed disabled, then it may be possible to exclude the script from LiteSpeed (instead of, or in addition to your Complianz exclusion). Though the placement of the comment seems strange – as though it is mistaking the et_frontend_nonce value for something else – so if an exclusion doesn’t help it might be worth checking with LIteSpeed’s support.
Hope that helps this time!
I’d like to know, what would be the best way to get at this issue before adding any further changes.
The page I need help with: [log in to see the link]
- The topic ‘Conflict with Divi’ is closed to new replies.