Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8565873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:31:43+00:00 2026-06-11T17:31:43+00:00

I am using google fonts api. In document.ready i requested the google fonts collection

  • 0

I am using google fonts api. In document.ready i requested the google fonts collection and populate the select list with all available font-families. Now when user select any font from selectlist i just append the link in the document which request the selected font and show the font-preview. But i am trying to show the loading image while the font is loading for preview. My code :

    $("#ff").selectmenu({ select: function () {
        var img = $("<img />").attr("src", "/images/load.gif");
        $(".preview").append(img);
        $('body').append("<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=" + escape($(this).val()) + "' type='text/css' media='all' />");
        $(".preview").css({ fontFamily: $(this).val() });
        $(img).remove();
    }
    });

But the loading image is not showing because may be the link tag is requesting the font asynchronously. How can i show the loading image until the font is fully loaded ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:31:44+00:00Added an answer on June 11, 2026 at 5:31 pm

    Here is another answer provided by csuwldcat on another post.

    javascript: capturing load event on LINK

    Here’s what is, in my opinion, a better solution for this issue that
    uses the IMG tag and its onerror event. This method will do the job
    without looping, doing contorted style observance, or loading files in
    iframes, etc. This solution fires correctly when the file is loads,
    and right away if the file is already cached (which is ironically
    better than how most DOM load events handle cached assets). Here’s a
    post on my blog that explains the method – Back Alley Coder post – I
    just got tired of this not having a legit solution, enjoy!

    var loadCSS = function(url, callback){
    var link = document.createElement('link');
        link.type = 'text/css';
        link.rel = 'stylesheet';
        link.href = url;
    
    document.getElementsByTagName('head')[0].appendChild(link);
    
    var img = document.createElement('img');
        img.onerror = function(){
            if(callback) callback(link);
        }
        img.src = url; 
    

    }

    Please vote up his response, ensuring he gets credit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the google fonts api, the font looks great on Google, but
I'm using the Google webfonts API to embed Droid Sans on a page. All
I am using some Google Web Fonts. I hear that Google deal with all
I'm using a CSS file from the Google API: <link href=http://fonts.googleapis.com/css?family=Ruthie rel=stylesheet type=text/css />
I'm using the Ubuntu font from Google Fonts: <link href='http://fonts.googleapis.com/css?family=Ubuntu:300,400,300italic,400italic,500,500italic,700,700italic' rel='stylesheet' type='text/css' /> My
I have a question about Google Fonts. I am using the font Lato from
I am using Google's web font api with the font Lato, font-weight of 100.
I'm using google font api, this code works when I move the font-family line
I'm using Google Font API to display my website logo. (See top of stolencamerafinder.com
I'm using this script to retrieve a list of Google web fonts. How can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.