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

  • Home
  • SEARCH
  • 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 6795665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:22:27+00:00 2026-05-26T18:22:27+00:00

I am loading a script from the google plus button only when the user

  • 0

I am loading a script from the google plus button only when the user requests it. The code that is used is the following:

    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);

When I fire this script it will change the placeholder into the google plus button. The placeholder looks like this:

<g:plusone size="tall" annotation="none"></g:plusone>

There are a few other buttons I load like this, only when needed.

Now sometimes the buttons take a while to load. Is there a way get an alert when all the buttons are loaded.

I can then just display a loader until it is fully loaded, and then display it nicely.

I use jQuery as my javascript framework.

Edit

For a better solution check out this question: Invoking handler when all scripts finished loading via $.getScript

A better way to go is using jQueries deffered object. I added a small example and fiddle to the answer.

  • 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-05-26T18:22:27+00:00Added an answer on May 26, 2026 at 6:22 pm

    jQuery provides a mechanism to define a script load handler:

    $.getScript( 'https://apis.google.com/js/plusone.js', function () {
        // the script has loaded and executed
    });
    

    This handler is invoked after the script has executed, so it should suit your needs…

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

Sidebar

Related Questions

I'm trying to block a script file from loading on user defined websites. To
I have a website which is loading jQuery from Google's CDN servers: <script type=text/javascript
I've got the following code in my headers to load a font from Google's
Here's code from https://github.com/Khan/khan-exercises/blob/master/khan-exercise.js for ( var i = 0; i < loading; i++
I have a Google Map (API 2) that used to work fine as a
I'm struggling with the asset pipeline. I'm loading dojo from Google CDN putting this
So, this question tells me that jQuery ajax requests don't insert script tags into
Error loading script occurs under FireFox 3 if I quickly click different links on
After loading a PHP template (using jQuery's load function), this simple script won't make
$('a').click(function(event){ $('body').html('loading...'); $.post('www.sitename.com/hello',{site:http//:www.google.com},function(data) { alert(data); }); event.preventDefault(); }); I am using the above script

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.