A progressive JPEG image is made up of a series of "Scans". Each Scan provides progressively more information for each MCU block (more A/C coefficients). The first scan is usually just the DC values for each MCU. This happens to be the perfect amount of information to get you a 1/8th sized thumbnail image.
In the JPEG file, each scan starts with a SOS (start of scan) marker of FFDA. In order to know how much data is needed to completely hold the first scan, simply search the file data for the start of the second scan (the second FFDA marker) and you have your answer. Because of the marker byte rules, the 2 byte sequence FF DA cannot be anything but the SOS marker. Compressed data which needs to encode the value FF followed by DA would have to be encoded as FF 00 DA.
We’re basically forced to switch to self hosting due to the bizarre way Google implements statistics for Google Fonts. 1 out of 1000 requests will include a “tracking font” which is actually invalid and breaks document.fonts.load. This was an incredibly frustrating bug to track down.