BibleGet-I-O / bibleget-wordpress

Plugin for WordPress that let's you insert Bible quotes into your posts or pages from a variety of Bible versions in different languages. This is a mirror of the SVN repo where the plugin gets published to the WordPress plugins store. Kudos to @kas-catholic for helping import the repo from SVN.
https://www.bibleget.io
Apache License 2.0
0 stars 2 forks source link

Too many requests to the Google Webfonts API #28

Open JohnRDOrazio opened 1 month ago

JohnRDOrazio commented 1 month ago

For some reason, when an API key is enabled for Google Webfonts, too many requests are sent to the API bringing the API usage to the 10000 request limit in a single day.

We need to inspect better what exactly is happening and how so many daily requests are being sent.

JohnRDOrazio commented 1 month ago

So we have succeeded in retrieving an actual .woff2 file rather than .ttf files, which cuts the size of the font files practically in half.

Now we just need to take care of the font loading issue. Rather than load a css file that declares all of the possible font faces (resulting in over a thousand requests for local resources that are therefore blocked by the browser) we should implement the CSS Font Loading API, loading only those fonts that are actually in view in the dropdown list. This will mean knowing which fonts are currently in view in the dropdown, and loading a discreet number of font resources beyond that limit (before and after).

The next best thing would be to generate images from the fonts, and perhaps combine them into a single image file, and then display the portions of the image using coordinates.

The absolute best would be to implement the new WordPress Font Library (which I believe will only be available for themes with Full Site Editing capabilities?), and only fall back to the more tedious implementation when a classic theme is in use.