Upon loading my page, I run a JavaScript function to determine if specific text fits within its parent div. If it doesn't fit, then adjustments must be made.
The text is styled with a custom font, which can be loaded either through @font-face or Google fonts, depending on the font chosen.
An issue arises when the JavaScript executes before the font has been fully applied, resulting in incorrect measurements due to variations in font size and width.
UPDATE: In response to feedback:
I have placed the CSS in the header and the JavaScript at the end of the document. Despite enclosing all my code within:
$(document).ready ( function(){...})
the problem persist.
With caching disabled, the height is calculated incorrectly. Enabling caching yields accurate measurements, presumably because of the time required to apply the font.