Page MenuHomePhabricator

Avoid third party resources from *.wikimedia.it websites
Closed, ResolvedPublic3 Estimated Story Points

Description

There are some third party resources on the www.wikimedia.it website. Some of them:

  • fonts.googleapis.com (thanks to T282613)
  • ajax.googleapis.com (thanks to T282613)
  • google.com (thanks to T282613)
  • gstatic.com
  • webarea.services (this is simply our CRM service provider)

There are also third party resources that should be removed from sostieni.wikimedia.it (info):

How:

  • just dropping these dependencies
  • or replacing them with local replacements

See also:

Event Timeline

valerio.bozzolan set the point value for this task to 3.

This is trivial to do, you only have to go to the admin page and set it to use local fonts. If the chosen font is not available, you upload it locally. For reference the administrator can look at our previous Wordpress installation which used to be at www.wikimedia.it, where all these problems had already been solved.

This is trivial to do, you only have to go to the admin page and set it to use local fonts. If the chosen font is not available, you upload it locally. For reference the administrator can look at our previous Wordpress installation which used to be at www.wikimedia.it, where all these problems had already been solved.

Yup. Me and you could fix the external fonts with great pleasure. Sadly our upstream provider has an exclusive management at the time of writing... for example the WordPress theme is read-only and no FTP credentials were provided to the association.

(Talking with @Maupao70 few days ago he confirmed that these things will be re-discussed with the provider during the next meeting to be held next week.)

valerio.bozzolan renamed this task from Avoid third party resources from wikimedia.it to Avoid third party resources from www.wikimedia.it.Feb 8 2021, 8:36 AM
valerio.bozzolan updated the task description. (Show Details)

To avoid having to download fonts every time (which increases costs) we can eventually implement a Google Font proxy cache in Wikimedia Italia.

I successfully implemented this in Border Radio some days later:

https://gitpull.it/T776

Maybe we can expose such service as http://gfont-cache.wikimedia.it or whatever. What do you think about @Nemo_bis @Laurentius?

Nice! But wouldn't be simpler to just make a local of the fonts we use?

Nice! But wouldn't be simpler to just make a local of the fonts we use?

Indeed. asd

Nice! But wouldn't be simpler to just make a local of the fonts we use?

This was also the point of view of the company that manages the site. After a month they didn't make the change.

To be honest I also absolutely don't know how to replace the dynamic fonts picked by the fancy WordPress editor. I'm starting to think the proxy is really simpler.

Well, the point is to have a simple way to avoid third-party resources; whatever is simpler is ok.

Well, the point is to have a simple way to avoid third-party resources; whatever is simpler is ok.

Uhm. Yup. We can... shutdown the website! Thaaat's a simple red button to avoid this and much other issues!

asd

Well, why do we need a Wordpress website when we already have a wiki, after all? :-)

So. I've done some A/B tests after this:

And we were able to kill 3 of the listed dependencies:

  • fonts.googleapis.com
  • ajax.googleapis.com
  • google.com

With this snippet:

1<?php
2/*
3 * Enable a Google Font proxy
4 *
5 * Author: Valerio Bozzolan
6 * License: GNU General Public License v2 or later
7 * Date: 2021
8 *
9 * See https://phabricator.wikimedia.org/T282613
10 * See https://gitpull.it/T776
11 * See https://gitpull.it/R26:f8b39ca15e8ba48a92fb0d58c2772e9b02691059
12 */
13
14/**
15 * Local Google Font cache
16 */
17define( 'GOOGLE_FONT_PROXY', 'fonts.wikimedia.it' );
18
19/**
20 * Convert a Google Font domain to your local proxy cache
21 *
22 * See https://phabricator.wikimedia.org/T266998
23 */
24function convert_google_font_to_local_proxy( $url ) {
25 return str_replace( 'fonts.googleapis.com', GOOGLE_FONT_PROXY, $url );
26}
27
28/**
29 * Avoid Google Fonts in your stylesheets
30 *
31 * https://phabricator.wikimedia.org/T282613
32 */
33add_filter( 'style_loader_src', 'convert_google_font_to_local_proxy' );
34
35/**
36 * Avoid Google Fonts in your DNS prefetch
37 *
38 * https://phabricator.wikimedia.org/T282613
39 */
40add_filter( 'wp_resource_hints', function( $urls ) {
41 foreach( $urls as & $url ) {
42 $url = convert_google_font_to_local_proxy( $url );
43 }
44 return $urls;
45} );

I think everything is OK but if something goes wrong we can just uncomment this line from /wp-content/wmi/functions.php:

/**
 * Avoid third party resources from www.wikimedia.it
 *
 * https://phabricator.wikimedia.org/T266998
 */
require 'google-font-proxy.php';

Now let's kill:

  • gstatic.com
  • webarea.services

Going to https://www.wikimedia.it/ I still see rel=stylesheet type=text/css href="https://fonts.googleapis.com/css?display=swap&amp;family=Roboto:300,400&amp;subset=latin" media=all> so I'm going to uncheck the first item in the list.

Aklapper updated the task description. (Show Details)
Aklapper unsubscribed.
In T266998#7153072 wrote:

Going to https://www.wikimedia.it/ I still see rel=stylesheet type=text/css href="https://fonts.googleapis.com/css?display=swap&amp;family=Roboto:300,400&amp;subset=latin" media=all> so I'm going to uncheck the first item in the list.

D:

Probably caused by a recent plugin update. Reported to the appointed company.

OK. It seems the last fonts.googleapis.com was caused by a WordPress plugin called Smart Slider. If you have Smart Slider in your website, do this:

  • Smart Slider > Settings > Fonts
/wp-admin/admin.php?page=smart-slider3&nextendcontroller=settings&nextendaction=fonts

Then uncheck:

  • Google - Frontend
  • Google - Backend

Just to say that the mailing list iframe (not handled by us) now does not require anymore Google resources.

More info here:

https://wiki.wikimedia.it/wiki/Fornitori/np/Risorse_esterne_form_GIVE

Facebook is no longer an external resource in https://sostieni.wikimedia.it/ in any way.

The provider still have to replace the Google Fonts. We suggested our endpoint:

valerio.bozzolan renamed this task from Avoid third party resources from www.wikimedia.it to Avoid third party resources from *.wikimedia.it websites.Mar 22 2022, 12:06 PM

I'm marking it as solved because I can't find any other nonsense external dependency at the moment.

Further problems can be reported also here as usual: