Alright Thank you. That is exactly the kind of answer I was looking for. See, I don't use $.getScript in place of <script>, and I wasn't planning on it either. I read about the function and wanted to test it, and was confused as to why it did not work. Thank you, On Mon, Sep 7, 2009 at 8:07 PM, Michael Geary <m...@mg.to> wrote:
> Why do you want to use $.getScript to load those .js files? Is there a > reason you don't want to use <script> tags? > > I would never expect this code to work properly, in any browser: > > $.getScript(root+'scripts/ui/1.8a1/ui/ui.core.js'); > > > > $.getScript(root+'scripts/ui/1.8a1/ui/ui.draggable.js'); > $.getScript(root+'scripts/ui/1.8a1/ui/ui.resizable.js'); > $.getScript(root+'scripts/ui/1.8a1/ui/ui.dialog.js'); > > It's just a lucky bonus that it ever works in some browsers. Even there I > wouldn't count on it working in all situations. > > The problem is that $.getScript is *asynchronous* and does not guarantee > any particular order of loading. <script> tags, OTOH, behave as if they were > synchronous: The scripts will always be executed in the same order as the > <script> tags. (The actual file loading may be asynchronous, but the script > *execution* is always in the order you expect.) > > When you load those files with <script> tags, ui.core.js always executes > first, and the other ui.*.js files - which depend on ui.core.js - execute > later. This is guaranteed behavior in all browsers. > > When you use $.getScript, the scripts are loaded willy-nilly and executed > whenever they happen to be ready. ui.core.js could easily get loaded * > after* the scripts that depend on it. > > Another problem with $.getScript() is that any script that uses > document.write() will fail when loaded this way. document.write() only works > when the page is being initially loaded, not when you load a script > asynchronously with $.getScript() or equivalent. That's probably not the > problem here, but it's something to watch out for. > > -Mike > > > On Mon, Sep 7, 2009 at 3:51 PM, Ross Hadden <rosshad...@gmail.com> wrote: > >> The website in question is http://os.rosshadden.com/ >> >> The only change needed to change it from working to the state it is in now >> is changing the script calls from <script/> to $.getScript >> >> >> >> On Mon, Sep 7, 2009 at 5:00 PM, Michael Geary <m...@mg.to> wrote: >> >>> Unless there is a known issue, I don't think anyone can answer your >>> question based on the information you've provided. >>> Can you post a link to a test page that demonstrates the problem you've >>> encountered? That would allow people to actually take a look at it and try >>> it for themselves in Chrome and other browsers. >>> >>> -Mike >>> >>> On Mon, Sep 7, 2009 at 12:58 PM, Ross Hadden <rosshad...@gmail.com>wrote: >>> >>>> Anyone? Please? >>>> >>>> >>>> On Sat, Sep 5, 2009 at 6:14 PM, rosshadden <rosshad...@gmail.com>wrote: >>>> >>>>> >>>>> Is it a known issue that $.getScript() does not work in Chrome, or >>>>> could I be doing something wrong? >>>>> >>>>> I am able to load scripts using this function in any browser, but in >>>>> order for me to be able to use their contents in Chrome I need to put >>>>> blocks of code in the callback of $.getScript. While it makes sense >>>>> that I would not be able to utilize a script's functions outside of >>>>> its callback, why then does it work in both Firefox and IE? >>>>> >>>>> For me using the ol' <script/> works without any issues, but I was >>>>> trying to use $.getScript() in place of that for experimental >>>>> purposes. Is this the wrong application for the function? Should I >>>>> only use it if I need to load a script on the fly? >>>>> >>>>> Thanks, >>>>> ~Ross >>>>> >>>> >>>> >>>> >>>> -- >>>> ~Ross >>>> >>> >>> >> >> >> -- >> ~Ross >> > > -- ~Ross