Solved

How Can I Delay Loading an External Javascript?

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

We have come a long way with backup and data protection — from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now