joomtools / plg_system_jtaldef

Automatic local download external files
GNU General Public License v3.0
16 stars 6 forks source link

Questions about google access #2

Closed xorx1 closed 2 years ago

xorx1 commented 2 years ago

The task of your plugin is to avoid fetches to google. My Joomla site still shows the following fetches:

1. GET https://fonts.googleapis.com/css2?family=Dosis:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,800&display=swap
2. GET https://fonts.gstatic.com/s/dosis/v25/HhyaU5sn9vOmLzloC_WoEoZK.woff2
3. GET https://fonts.gstatic.com/s/dosis/v25/HhyaU5sn9vOmLzloC_WoEoZK.woff2
4. GET https://fonts.gstatic.com/s/dosis/v25/HhyaU5sn9vOmLzloC_WoEoZK.woff2

Nor. 1 is trying to fetch a font that is not available. This is the reason why it is not cached by your plugin as you explained in #1. But this situation leads to an unintended fetch to google. Wouldn't it be better to cache this fetch too even if it was not successfull? This way you would avoid this access to google. Of course I could try to hunt down by which formatting this font request is created, but this seems to be close to impossible. Would this be worth an extension of the plugin?

No. 2 to No. 4 is fetching an existing font of the dosis family that should have been cached.

/* latin */
@font-face {
  font-family: 'Dosis';
  font-style: normal;
  font-weight: 200;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/dosis/v25/HhyaU5sn9vOmLzloC_WoEoZK.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

I activated scanning in style attributes in head and body but that did not change anything. Any idea why this one is not catched? 73 other fonts are correctly cached.

degobbis commented 2 years ago

My way of thinking is as follows:

Someone goes to https://fonts.google.com/ to pick a font like https://fonts.google.com/specimen/Dosis?query=dosis and selects the styles.

Then one gets the implementation options displayed (<link> or @import).

Both options automatically download a CSS from Google for the @font-face, so there is no need to check for No. 2 to No. 4. Once the implementation link is replaced, the CSS with the @font-face is also recreated by the plugin and linked to the local font.

So if someone also writes the @font-face with direct links to the Google Font, they are doing more than necessary and thus fall out of the norm.

As explained in my description, I only support the ways offered for implementation.

How the plugin could react if a font can't be loaded is another discussion, because simply deleting it without feedback is not the right way and feedback should not be openly visible on the website.

xorx1 commented 2 years ago

How the plugin could react if a font can't be loaded is another discussion, because simply deleting it without feedback is not the right way and feedback should not be openly visible on the website.

What about reporting it in debug mode only while deleting it in normal mode?

Concerning No 2 to No 4 I have to admit that I am not familiar with font management in joomla and web font handling. So I can not tell who/where/why these direct links to gstatic are created. That is why I thought your plugin could catch it.

degobbis commented 2 years ago

Regarding No. 2 to No. 4: Since this is not Google's suggested method of inclusion, I don't think the benefit/effort factor is justified.

Regarding reporting: I think this makes sense and will also think about how this can best be implemented.

Thanks for your feedback.