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

    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>';
        return $event;