Solved

How Can I Delay Loading an External Javascript?

Posted on 2010-11-30
2
543 Views
Last Modified: 2012-05-10
Hi everyone, I have an external .js file that I need to load on a website. I have no control over the file itself, just the ability to call it into a webpage.

I am currently using the following code.
<script src="http://externalsite.com/file.js" type="text/javascript"></script>

Open in new window


I would like to be able to delay that by say 10 seconds from running. Does anyone have any suggestions? Thanks!
0
Comment
Question by:MikeC7
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 34241038
setTimeout('loadit();', 10000);
function loadit() {
  s = document.createElement('script');
  s.src="http://externalsite.com/file.js";
  document.getElementsByTagName('body')[0].appendChild(s);
}
0
 

Author Closing Comment

by:MikeC7
ID: 34242088
Works like a charm..and you posted this from a mobile app. You rule!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Apache-Tomcat Single Sign On with NTLM/Kerberos on Windows 2008R2 3 214
TreeSet comparator example 7 95
Problem with small jquery script 6 52
javascript issues 2 81
For months I had no idea how to 'discover' the IP address of the other end of a link (without asking someone who knows), and it drove me batty. Think about it. You can't use Cisco Discovery Protocol (CDP) because it's not implemented on the ASAs.…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question