Solved

How Can I Delay Loading an External Javascript?

Posted on 2010-11-30
2
549 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
In this blog we highlight approaches to managed security as a service.  We also look into ConnectWise’s value in aiding MSPs’ security management and indicate why critical alerting is a necessary integration.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

696 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