PDA

View Full Version : Can I make my DOM script asynchronous? (Not AJAX...)


AaronW
10-07-2006, 07:07 PM
I've got a script that, onload, loops through every tag on the page (getElementsByTagName ('*')) and can be pretty slow on some of my pages with MANY tags.

What I'm wondering is if there's some way I can tell the browser to run the script asynchronously, without locking up the browser while it loops through all the tags and adds its objects and properties to them?

I'm pretty sure I've made the script about as effecient as possible. There's just no way around checking all the tags.

Thanks for any suggestions,
Aaron

felgall
10-07-2006, 10:35 PM
You can only make Javascript asynchronous by using functions that work that way such as setTimeout and setInterval. They basically return control during a pause in the processing. There is no way to make Javascript asynchronous without stopping the Javascript from running during the period in which you want to give control back to the page.

AaronW
10-08-2006, 03:24 AM
Nuts.

Thanks, though.

Beagle
10-09-2006, 02:26 PM
You could try to use setTimeout, it might work.