Fixes for Specific Packages

Here you will find a list of Packages that need a little help working with Instant Page Speed Magic, along with a way to make them work together nicely.

 

GDPR + Cookie

If you set GDPR + Cookie to show a cookie consent banner and at the same time enable JavaScript tags optimization in Instant Page Speed Magic, the banner will not be displayed.

To solve the problem, add the following code to the file application\bootstrap\app.php

Events::addListener(
    'on_before_render',
    function ($event) use ($app) {
        $gdpr = $app->make('Concrete\Core\Package\PackageService')->getByHandle('gdpr');
        if (is_object($gdpr) && $gdpr->isPackageInstalled()) {
            $configuration = $app->make('A3020\Gdpr\Cookie\Configuration')->getConfiguration();
            $view = \Concrete\Core\View\View::getInstance();
            $script = '<script>';
            $script .= 'if (typeof defer !== "undefined") {';
            $script .= 'defer(function(){';
            $script .= 'if (typeof window.cookieconsent != "undefined" && typeof document.getElementsByClassName("cc-revoke")[0] == "undefined") {';
            $script .= 'window.cookieconsent.initialise(' . json_encode($configuration) . ')}}, 200);';
            $script .= '}';
            $script .= '</script>';
            $view->addFooterItem($script);
        }
        return $event;
    }
);

 

Genesis Theme

If you use any of the parallax functionality included with the Genesis theme you might see weirdly positioned images on your page.

As an FYI, this fix will probably work with any themes from the same developer (c5box) using parallax.

To solve the problem, add the following code to the footer from your dashboard page /dashboard/system/seo/codes

<script>
var i =0;
var checkParallaxLoaded = setInterval(function() {
    i++;
    if (i > 50) {
        // if not loaded after 5 seconds it's probably not loading on this page so we cancel
        clearInterval(checkParallaxLoaded);
    }
    try {
        $('[data-parallax]').parallax();
        clearInterval(checkParallaxLoaded);
    } catch(e) {}
}, 100);
</script>