Solved

How Can I Delay Loading an External Javascript?

Posted on 2010-11-30
2
547 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Not everyone has adapted to a rapid advancement in technology; there are people who are reluctant or afraid to delve into this brave new world of IT. If you have a friend or a family member who suffers from the so-called technophobia, here is how yo…
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.

732 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