3

I need to measure the navigation of my site to determine the space available for a feature I am building. I recently added a custom font...

The trouble is that I measure the navigation before the new font is loaded. The new font then loads altering the width of the navigation. I am then left with an incorrect width.

Is there a way I can determine when the font has loaded with JavaScript. I am using CSS to load the font.

1 Answer 1

2

I assume you are waiting on $(document).load before running your jquery? This just waits for the DOM to become accessible. If you want to wait until the entire webpage (and associated files) are ready, use $(window).load:

$(window).bind("load", function() {
       //nav resize code here
});

I wouldn't wrap your entire code in this, just the part that is dependent on the fonts.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.