Found the URL of a CDN in the code: ajax.googleapis.com. You should not load CSS or Javascript resources from a CDN, please bundle them with the theme.

Hi,

I am trying to develop a theme and my theme has a Typography option that has Google font included in it in the customizer panel. And the Google font is served from the CDN.

And with the Envato Theme Check plugin, I keep getting the below notification as a required
“Found the URL of a CDN in the code: ajax.googleapis.com. You should not load CSS or Javascript resources from a CDN, please bundle them with the theme.”
And I suppose bundling 800+ Google Fonts with the theme is not a good idea at all.

Can anyone suggest me the proper way to include the Google Font Typography in the theme?

Thank you.

Loading Google Fonts from Google servers is completely legit (everyone is doing it). This look like maybe your implementation is wrong or something. I’ve never seen see such error in Envato Theme Check despite I am loading Google Fonts from the external source as well.
Use wp_enqueue_style hook to load it.

1 Like

Are you not able to use the fonts.googleapis.com CDN within a <link>? Seems like you’re using a script, which I would recommend you avoid.

e.g.

<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;300&display=swap" rel="stylesheet">