1

i just wondering is there any performance issue or anything thing wrong if that a $(window).load(), is set within a $(document).ready()

due to some element only can be determined after window is loaded such as dynamic size of an inline div or image, with height:auto, while 80% of the function should start working on document.ready.

devric
  • 3,555
  • 4
  • 22
  • 36

2 Answers2

1

Nopes, no issues.

[Quote] This works fine and is an acceptable practice. After all, as you describe, there may be cases where the logic in the $(window).load() handler depends on work taking place after the DOM is ready. If the window is in fact already loaded by the time you set up $(window).load(), the handler will just fire immediately. [UnQuote]

"$(document).ready() runs as soon as the DOM has loaded, but $(window).load() will not run until the DOM has loaded AND all dom resources have loaded (like images and CSS files and stuff). That means that $(document).ready() will run before you set the value." read more here

window load inside a document ready?

Hope this helps for your understanding you can always read more in Jquery documentations.

cheers!

Community
  • 1
  • 1
Tats_innit
  • 33,991
  • 10
  • 71
  • 77
  • I see, but I'm now facing one issue, the function carries, 3 parts, the first two part does not require window.load variables, but the last does. And it seem like it won't parse through, i probably have to break the plugin into two parts. – devric Mar 23 '12 at 12:21
  • hiya, okies; if you can give jsfiddle we might be able to help you further, but seems like you have better idea already. Hope this plugin if yours, (as you mentioned breaking i.e. refactoring or slicing down your code into halves) cheers. – Tats_innit Mar 23 '12 at 12:25
0

No. No issue with that at all.

You're just assigning an event handler to an event, which of course, will fire some time after DOMContentLoaded.

jAndy
  • 231,737
  • 57
  • 305
  • 359