You can define your own callback function, then use that to call the other callback function provided it exists:
if (typeof theCallback == 'function')
theCallback(arg1, arg2, arg3, etc);
Question
I have a Google Maps page that I am looking to optimize as it is heavily used. Currently, the user does the following to search:
The xml file request can take a signficant amount of time (a few seconds) due to external factors (api). I am hoping to request this xml file before the page has fully loaded to speed up the request. Unfortunately, this request uses a callback that has not been defined until an external asset has been loaded.
What is the best way for me to prefetch the xml file, and setup a callback for a function that has not been loaded yet? Basically, I want to load the xml file at the top of the page, and wait to call the callback function until it has been retrieved.
Solution
You can define your own callback function, then use that to call the other callback function provided it exists:
if (typeof theCallback == 'function')
theCallback(arg1, arg2, arg3, etc);