Skip Navigation

[Resolved] Disable Google Fonts oin Google Maps

This support ticket is created 2 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by jochenF-2 2 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#2489523

I have a map loaded via toolset on my website and it injects the fonts roboto and google sans. How can i prevent the map to load them?

Best Jochen

#2491011

Hi Jochen,

Thank you for contacting us and I'd be happy to assist.

I did some research online and found this script, that prevents the fonts from Google Maps from loading:
( source: https://stackoverflow.com/a/50983518 )


(function($) {
var isGoogleFont = function (element) {
    // google font download
    if (element.href
        && element.href.indexOf('<em><u>hidden link</u></em>') === 0) {
        return true;
    }       
    return false;
}

// we override these methods only for one particular head element
// default methods for other elements are not affected
var head = $('head')[0];

var insertBefore = head.insertBefore;
head.insertBefore = function (newElement, referenceElement) {
    if (!isGoogleFont(newElement)) {
        insertBefore.call(head, newElement, referenceElement);
    }
};

var appendChild = head.appendChild;
head.appendChild = function (textNode) {
    if (!isGoogleFont($(textNode)[0])) {
        appendChild.call(head, textNode);
    }
};
})(jQuery);

It worked on my test website and you can include it in your content template's "JS editor".

regards,
Waqar

#2491033

Hi Waqar,
my issue is resolved now. Thank you!