Chris Maguire
Chris Maguire

Reputation: 45

Autostop page from loading after 10 seconds

I have advertisements and scripts that run on my forum, and sometimes the page continues to load forever because those scripts aren't loading on time (i.e. Facebook, Adsense). Does anyone have a JavaScript that would automatically stop the page from this continuous load after, say, 10 seconds?

Upvotes: 0

Views: 1025

Answers (2)

Chankey Pathak
Chankey Pathak

Reputation: 21676

How can you be sure that your page will be loaded in 10 seconds? What if the user has poor internet connection/speed?

What I would suggest you is to put the JavaScript of advertisements and tracking (anaylytics) etc at the end of the page. Or if you can use jQuery then put this in ready function, so that when the document/page is ready, then you start calling JS functions for advertisements and all.

$( document ).ready(function() {
  // your code goes here
});

Upvotes: 1

deadulya
deadulya

Reputation: 706

Add js:

setTimeout(window.stop,10000);

Upvotes: 0

Related Questions