views:

202

answers:

2

I need to prioritize scripts so jQuery, Cufon, and my .js files come before Twitter does. I've tried defer="defer" as well as placing scripts in the bottom in the order I want them to execute but all these methods aren't working.

I don't want to modify Twitter's files either. Anything I can do?

+1  A: 

Have your script create the html to have the Twitter script downloaded. That way it will be loaded and executed after your script, which comes after jQuery and Cufon.

James Black
I'm amazed that worked...
Brandon Wang
A: 

Remember that defer is not standard and only supported by IE. Also, give more information. "aren't working" isn't a lot to go by. The order of compiling and executing Javascript is well define, so if you're doing things right they should execute in the right order. However, remember that a syntax error in any block will forbid the entire block from executing, so make sure something you think is running earlier is actually running at all.

ironfroggy
IIRC, FF3.5 supports defer as well. It's also being codified in HTML5, so expect more support across browsers (webkit, for example, is already working on it — https://bugs.webkit.org/show_bug.cgi?id=20710)
kangax
I'm fairly sure my code is correct: it all runs, but Twitter holds Cufon, jQuery, etc. from running and the website looks ridiculous. Also, the jump is unacceptable. In the end I just used append() to add the Twitter code. It was my understanding that this wouldn't work so I was very surprised when it worked.
Brandon Wang