views:

50

answers:

4

I'm using the jQuery document ready method - $(function()

If the page takes too long to render (say 2mins+), will this be the reason for the page throwing a javascript taking too long to execute error/warning?

A: 

No the document.ready only loads after the DOM is ready (i.e after the jquery core is loaded and ready to be used), so it will not throw any error, if a page takes 2-3 mins.

Starx
+2  A: 

No. $(function(){}) will get called once the DOM is loaded - i.e. it doesn't keep running throughout the load process. Unless you are trying to do a long running synchronous task or stuck in a long loop, you shouldn't get that error.

Have a look at the CPU utilization. If it's high for the browser, it's a tell tale sign that there is an infinite loop somewhere.

Igor Zevaka
good answer and tip.
Brandon
+1  A: 

depends what you mean by "render".

if you are doing some intense processing in JS (like calculating the millionth prime number or something), the browser will display that message. if you are waiting for a resource to load and aren't grinding away on some script, you will be ok.

gga80
A: 

It shouldn't - but test it.

To find out a little more, why not comment out your current load function, and put in a really simple load function, something like:

 $(document).ready(function() { alert("load firing");}

See if that makes a difference. Add stuff back in until it breaks.

seanb