I have seen a few times that some are not putting code in $(document).ready, so are sometimes asking why their code does not work, e.g. you may see this ... <script type="text/javascript"> $("#mydiv").slideDown(); </script> </head> <body> <div id="mydiv">...
Would it be possible for jQuery to delay execution if no element is matched and the page isn't fully loaded? That way #myDiv will slide down as expected.
I disagree. There are times, albeit rare ones, when you want to do some things before the document is ready. Any attempt to do so, however, should console.log a warning, because that's not what you want most of the time.
> I have seen a few times that some are not putting code in > $(document).ready, so are sometimes asking why their code does not > work, e.g. you may see this > ... > <script type="text/javascript"> > $("#mydiv").slideDown(); > </script> > </head> > <body> > <div id="mydiv">...
> Would it be possible for jQuery to delay execution if no element is > matched and the page isn't fully loaded? That way #myDiv will slide > down as expected.
On 13/02/07, Brian Miller <bjmil...@bway.net> wrote:
> I disagree. There are times, albeit rare ones, when you want to do some > things before the document is ready. Any attempt to do so, however, > should console.log a warning, because that's not what you want most of the > time.
> - Brian
That's why I suggested only to wait if the element is not found. So with the following, the div is slid down before the document is ready:
> > I have seen a few times that some are not putting code in > > $(document).ready, so are sometimes asking why their code does not > > work, e.g. you may see this > > ... > > <script type="text/javascript"> > > $("#mydiv").slideDown(); > > </script> > > </head> > > <body> > > <div id="mydiv">...
> > Would it be possible for jQuery to delay execution if no element is > > matched and the page isn't fully loaded? That way #myDiv will slide > > down as expected.
> I have seen a few times that some are not putting code in > $(document).ready, so are sometimes asking why their code does not > work, e.g. you may see this > ... > <script type="text/javascript"> > $("#mydiv").slideDown(); > </script> > </head> > <body> > <div id="mydiv">...
> Would it be possible for jQuery to delay execution if no element is > matched and the page isn't fully loaded? That way #myDiv will slide > down as expected.
John actually had some code that did just that. But in most cases it works around a programming error that should be fixed instead, therefore it never got to wider public. The additional code and possible performance lost isn't really worth it.
> Sam Collett schrieb: > > I have seen a few times that some are not putting code in > > $(document).ready, so are sometimes asking why their code does not > > work, e.g. you may see this > > ... > > <script type="text/javascript"> > > $("#mydiv").slideDown(); > > </script> > > </head> > > <body> > > <div id="mydiv">...
> > Would it be possible for jQuery to delay execution if no element is > > matched and the page isn't fully loaded? That way #myDiv will slide > > down as expected.
> John actually had some code that did just that. But in most cases it > works around a programming error that should be fixed instead, therefore > it never got to wider public. The additional code and possible > performance lost isn't really worth it.
Let me guess - was it Internet Explorer that proved to be troublesome? Using setInterval is the only way I can think of for doing this (but could slow down the browser if there is lots of code calling it).
> On 13/02/07, Jörn Zaefferer <Enc...@gmx.net> wrote: > > Sam Collett schrieb: > > > I have seen a few times that some are not putting code in > > > $(document).ready, so are sometimes asking why their code does not > > > work, e.g. you may see this > > > ... > > > <script type="text/javascript"> > > > $("#mydiv").slideDown(); > > > </script> > > > </head> > > > <body> > > > <div id="mydiv">...
> > > Would it be possible for jQuery to delay execution if no element is > > > matched and the page isn't fully loaded? That way #myDiv will slide > > > down as expected.
> > John actually had some code that did just that. But in most cases it > > works around a programming error that should be fixed instead, therefore > > it never got to wider public. The additional code and possible > > performance lost isn't really worth it.
> Let me guess - was it Internet Explorer that proved to be troublesome? > Using setInterval is the only way I can think of for doing this (but > could slow down the browser if there is lots of code calling it).