> From: Alex Weber > > Currently what I'm doing is: > > 1) Call function 1, checks for jQuery and if not then loads > the library and recursively checks until its available. > 2) Once its available, a second function is called and does > the same thing to load a plugin > 3) Ditto for my custom .js file
You really need to post a link to a test page that illustrates your loading technique. Or at least, post a complete HTML+JS example with real code in a message here. >From your description, it's anyone's guess what you're actually doing. Does "loads" mean "document.write() a script tag", or "create a dynamic script element", or what? Does "recursively" mean repeated calls to setTimeout? (BTW, that may look recursive, but it isn't.) Does "checks" mean... Well, you get the idea. My guess was that you're using dynamic script elements to load the .js files, and watching for certain symbols becoming defined on repeated setTimeout calls. But that is such a complicated solution that I have to think I guessed wrong. > I don't like this because of the excessive opening and > closing of connections required... is combining libraries + > custom code into 1 file a terrible pratice? Of course not! Who ever said combining .js files was a terrible practice? The fewer the files you download, the better. Combine all of your .js files into a single file, with the likely exception of jquery.min.js since you can let Google pay for that one. > Any other decent way to get by this step-by-step rudimentary approach? Well, tell us in painstaking detail exactly what you need to accomplish. Is this just an HTML page that needs to load some .js files? Like, "Hello? Script tags?" Since you currently have a more complicated method, there must have been some reasons you chose that - something that a plain script tag wouldn't accomplish? BTW, if you do use Amazon S3 as I suggested, there is one wrinkle: They don't GZip your files for you - you have to take care of that yourself. But forget that for the moment and let's make sure the problem you're trying to solve is clearly explained. So post your current code and your requirements, and let's take it from there. -Mike