javaScript OnDomReady ... prioritizing?

Sep 29, 2004
18,656
68
91
I am doing PHP code for a web site.

I have many php files that include eachother.

To keep things organized I place javascript in appropriate locations with a handful of OnDomReady calls.

Is there any way to prioritize the order the the callbacks are called? Prioritizing them would work nicely.

Thanks.
 
Sep 29, 2004
18,656
68
91
What do you mean by Daisy chaining the callbacks?

Make one OnDOMReady callback that calls a bunch of javascript functions and/or have those functions call the methods they need?
 

uclabachelor

Senior member
Nov 9, 2009
448
0
71
What do you mean by Daisy chaining the callbacks?

Make one OnDOMReady callback that calls a bunch of javascript functions and/or have those functions call the methods they need?

Either way would work.

If you are not using ajax then you can use a main ready function to execute the functions in the order you set.

If you are using ajax then you would have to set the next function call within the response handler of the first ajax call since ajax execution is asynchronous.

Although I suspect that the problem you are having can better be solved by redesigning the way the javascript and files are included.
 
Sep 29, 2004
18,656
68
91
I have one minor annoyance that it not repeatable. I am pretty much certain as to why it is happening. I even think that it is easily fixable with my current code base.

I am using YUI2 which uses AJAX under the hood.

I have considered moving javascript to different locations.

Anyway, I think I will be calling a certain function from a specific callback.
 

sourceninja

Diamond Member
Mar 8, 2005
8,805
65
91
I typically put all my javascript (or includes) at the bottom of my html documents.