Remove Google Maps API



  • Hello there,

    I’m just trying to optimize the speed of my page a little and most complains gtmetrix has come from the Google Maps api.

    Since I’m not using any map (front + backoffice), I want to simply remove the whole api.
    But…how?

    Can anyone tell me where the maps api is located?



  • Hello
    My Thirtybees front doesn’t load any Google Maps API.
    I think you have to disable any module that could load the Google Maps API or may be check if it’s your theme that loads it.



  • Hmm, is there a way to trace it back?
    I can’t see a module that seems obvious.

    But perhaps I just ask the template-support.



  • Ah ok, it actually was a module - in my case TM Mega Menu.
    I just edited the file modules > tmmegamenu > tmmegamenu.php

    Somewhere there (line ~2679) are two lines like this
    ’://maps.google.com/maps/api/js?region=’.Tools::substr($default_country->iso_code, 0, 2);

    I just removed the first part so it looks like this:
    :’’.Tools::substr($default_country->iso_code, 0, 2);



  • @manisch that’s not a good solution. This will probably create script tag in your page like this:

    <script type="text/javascript" src='httpen' />
    

    that will result in http request to your domain, ie: http://www.domain.com/httpen. Request will return 404 not found, and you’ll get error code in your console. Immediately after that you will find another couple of errors related to missing google maps library, because javascript code that utilize this library is still present…



  • @datakick hmm, right now everything seems fine.
    What would you suggest?



  • @Manisch I would need to see source code of the module. But I believe that the line you’ve mentioned starts with something like this:

    $this->context->controller->addJS(....
    

    You will want to remove the whole line. Next, search for text ‘google.maps’ in *.js files of this module… and get rid of all references to google maps api… somehow…



  • @datakick it might seem a little dirty, but I was just glad it works without error so far 😃 But it actually looks like this (XXX marks where once was the url)

            $google_script = 'http'.((Configuration::get('PS_SSL_ENABLED')
                    && Configuration::get('PS_SSL_ENABLED_EVERYWHERE'))
                    ? 's'
                    : '').'XXX'.Tools::substr($default_country->iso_code, 0, 2);
            $entry = strpos(implode(',', $this->context->controller->js_files), $google_part);
    

    and

            $this->context->controller->addJS('http'.((Configuration::get('PS_SSL_ENABLED')
                                                    && Configuration::get('PS_SSL_ENABLED_EVERYWHERE'))
                                                    ? 's'
                                                    : '').'XXX'.Tools::substr($default_country->iso_code, 0, 2));
            $this->context->controller->addJS($this->_path.'views/js/admin.js');```

 

Looks like your connection to thirty bees forum was lost, please wait while we try to reconnect.