Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How Can I Delay Loading an External Javascript?

Posted on 2010-11-30
2
Medium Priority
?
555 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 2000 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

636 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