victrme / Bonjourr

Minimalist & lightweight startpage inspired by iOS
https://bonjourr.fr
GNU General Public License v3.0
880 stars 104 forks source link

Makes a call to https://api.bonjourr.fr/fonts on every newtab #336

Closed Gitoffthelawn closed 4 months ago

Gitoffthelawn commented 5 months ago

Describe the bug Every time Bonjourr page is loaded, it makes a call to https://api.bonjourr.fr/fonts

To Reproduce Steps to reproduce the behavior:

  1. Install Bonjourr in Firefox
  2. Set Bonjourr as the page for about:newtab
  3. Open Firefox's Browser Console
  4. Open a new tab
  5. Notice the XHR call to https://api.bonjourr.fr/fonts
  6. Open another new tab
  7. Notice another XHR call to https://api.bonjourr.fr/fonts

Expected behavior Please only call https://api.bonjourr.fr/fonts if and when the data from that API is actually needed. If the user is only using local fonts with Bonjourr, calls to https://api.bonjourr.fr/fonts are never needed and thus should never occur. This will reduce your server's traffic, improve Bonjourr's performance, and improve privacy.

Device:

victrme commented 5 months ago

Thanks for the heads up @Gitoffthelawn, that behavior came back when I migrated from Google Fonts to Fontsource.

It will be improved very soon. In the next update (spoiler) the settings menu will only load on a user action (/spoiler). Which means Bonjourr will never need to fetch fonts unless you go in the settings.

Also your browser is almost never making an actual request because api.bonjourr.fr/fonts is cached for a month and is immutable. I'm using fetch because it is really convenient, but if the cache is set correctly, it's almost behaving like a local storage !

Gitoffthelawn commented 5 months ago

@victrme You're welcome, and as always, thank you too!

In regards to the API call in the upcoming release when the settings menu is opened... how about only when the user places the focus in the Font family input field?

In regards to making the actual requests in the current version, I don't employ much caching, so I'll double-check, but I think frequent calls are actually being made. But not a big deal, as you're about to change it anyways. :)

victrme commented 4 months ago

I added a call only on mouse hover as requested, everything was already there so it was easier than I thought.

I would argue that keeping some cache to avoid requesting assets every time is better for privacy! As long as cookies and session ids are cleared, the rest of the site data can stay. Might be wrong though.