• Resolved [email protected]

    (@brianfoxxrcom)


    Hi, first of all this plugin is very effective when improving our sites scores in page speedinsights, however there are still some issues left that needed fixing. Whenever we activate the plugin it speeds up the site but we can no longer do edits on our page through beaver builder plugin. I can see a lot of javascript errors when I’m trying to view the js status with chrome inspect element > console tab. Do you have some alternatives or tips to provide to make this plugin work with beaver builder.

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Plugin Author optimalisatie

    (@optimalisatie)

    Hi Brian,

    My apologies for the late reply. We do not provide support on this forum anymore. For future questions, please visit the Github forum:

    https://github.com/optimalisatie/above-the-fold-optimization/issues

    Thank you for reporting the issue!

    Some scripts do not natively support asynchronous loading. More information can be found in the following article about making Google AdSense scripts async compatible:

    https://support.google.com/adsense/answer/3221666?hl=en

    To solve the issue quickly it may be an option to exclude the conflicting scripts. For some scripts it may be a solution to encapsulate the code in jQuery(function($) { ... }); This could be done with a WordPress filter:

    function pagespeed_filter_html($searchreplace)
    {
        list($search, $replace, $search_regex, $replace_regex) = $searchreplace;
    
        # rewrite lsjQuery .ready() code
        $search_regex[] = '|(...script code match...)|s';
        $replace_regex[] = 'jQuery(function($) { $1 });';
    
        return array($search,$replace,$search_regex,$replace_regex);
    }
    add_filter('abtf_html_replace', 'pagespeed_filter_html', 10, 1);

    If you use Autoptimize for minification of inline javascript you could use a filter by Autoptimize:

    function pagespeed_filter_inline_js($JS)
    {
        if (strpos($JS, 'lsjQuery') !== false) {
            $JS = preg_replace('|(...script code match...)|s', 'jQuery(function($) { $1 });', $JS);
        }
        return $JS;
    }
    add_filter('autoptimize_js_after_minify', 'pagespeed_filter_inline_js', 10, 2);

    To understand the issue with async loading: some scripts depend on other scripts and when loading scripts asynchronously, the scripts will try to load as fast as possible independent from each other and independent from the HTML document. For some requests, the javascript files may be executed seconds after the HTML is loaded. For cached requests however, a script may be executed before the start of the HTML body. This may cause issues for some scripts. Using the jQuery encapsulation solution will make a script execute after the HTML is loaded, providing in stability that is sufficient for most scripts. When there are special dependencies however (such as with Google AdSense), it may be a little more complex to solve the issue.

    Let me know if you manage to resolve the issue!

Viewing 1 replies (of 1 total)
  • The topic ‘Beaver Builder is broken when this plugin is activated’ is closed to new replies.