Hey Vocal, I took a brief look at your page. I haven't looked at the actual SWFObject code, because generally speaking, if it's implemented correctly it's usually not the problem.
Using the Net Panel tool in Firebug, I was able to note that the number of connections being farmed out to your server, DNS lookups contribute to the lions share of delay for your page loading. Using this link (maybe outdated) as reference, it notes that there is a default max # of connections allowed from the same page by Firefox. I'm assuming that other browsers may have this limitation as well to make it slightly less trivial for a single browser to bring a web server to it's knees? http://groups.google.com/group/firebug/browse_thread/thread/04d1a83b9e39c947 I looked at your demo page, it didn't seem to hang for me, just took a bit using FF3.5 on a PC. Using IE8 on the same PC, I got similar performance characteristics. At first blush, it would seem like your server is the limiting factor, but maybe I'm wrong about that. ---- 15 minutes later. Took a gander at your code. You actually do something very similar to some work I did to deal with a random number of SWFObjects on a page in terms of pushing elements into an array and what not. You might want to consider abstracting these for loops you have into something called a SWFObjectManager class and instead of passing around the objects themselves which if you're not passing by reference might be more CPU work than not, that you just pass the element names around and only perform the operations as needed. You would need to test out which is more efficient though. SWFObjectManager.register("nameofDiv", "pathtoSWF", otherparams); SWFObjectManager.register("...","...",otherparams); if you use a lightweight framework like jQuery you could even tag your divs with something like class="swfobject" and then use a .each() selector to grab all the swfobjects on your page and then just instantiate your swfobjects based on the meta data on your page. i.e. <div id="foo" class="swfobject" >Alt Content</div> Then your JS would be potentially reduced quite a bit: $(document).ready(function() { $(".swfobject").each(function() { divId = $(this).id; swfName = divId+".swf"; properties = {data:swfName, width:100, height: 100}; parameters = {menu: false}; swfobject.createSWF(properties, paramters, divId); } } It does appear that you are reusing the global arrays for some reason, so for maintainabilities sake, you might consider upgrading your arrays to a type of SWFObjectManager class and make your calls a bit more compact. i.e. your SWFObjectManager class would use a loop like the one above to naturally grab all the divs of class swfobject and define them appropriately, so your inline JS gets reduced to: $(document).ready(function() { SWFObjectManager.init(); }); So sorry, stream of consciousness after Chinese New Year. If this confuses or is off point for you, then dump this in the recycle bin. Vincent On Tue, Feb 16, 2010 at 9:57 AM, VocalPlayboy <[email protected]> wrote: > Check out these 2 demos. > > First one the page hangs - > http://www.strangeloopstudios.com/swfobject_demo/ > > Second one there is a slight delay but at least it loads the page > quicker - http://www.strangeloopstudios.com/swfobject_demo2/ > > I'll also check out your app later, got to head out now, but thanks. > > Doug > > On Feb 16, 5:02 pm, Steve <[email protected]> wrote: > > Is it the size of your swfs themselves? If not, I have created an > > application that does what you want and writes the code for you. Just > > browse to your web page, drag and drop your swfs onto the page where > > you want them, set their properties, and click publish: > > > > http://norrisoftenhance.ning.com/ > > > > The application includes a getting started tutoriaal and help. > > > > Steve > > > > On Feb 16, 9:38 am, VocalPlayboy <[email protected]> wrote: > > > > > Hi All, > > > > > I'm building a modular video application with a bunch of Flex > > > components and part of the requirement is to use javascript as a > > > controller to communicate between my data model and my flex component > > > views. > > > > > The first part of this task involves embedding components to specific > > > div tags in a html page. I've got this to work great but it's just > > > really really really slow - like 10 seconds slow to embed 7 swfs. I've > > > tested and the issue is to do with swfobject (possibly because of the > > > way i've coded it). > > > > > Here's my HTML: > > > > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " > http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > > > <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> > > > <head> > > > <title>AMX JS Player</title> > > > <meta http-equiv="Content-Type" content="text/html; > charset=utf-8" / > > > > > <script type="text/javascript" > src="./html/swfobject/swfobject.js"></ > > > script> > > > <script type="text/javascript" > src="./html/amxjs/player.js"></ > > > script> > > > </head> > > > <body> > > > <div id="AMXJSPlayer_Model"> > > > <p>Model</p> > > > </div> > > > <div id="AMXJSPlayer_Category"> > > > <p>Category View</p> > > > </div> > > > <div id="AMXJSPlayer_Video"> > > > <p>Video View</p> > > > </div> > > > <div id="AMXJSPlayer_Meta"> > > > <p>Meta View</p> > > > </div> > > > <div id="AMXJSPlayer_Latest"> > > > <p>Latest View</p> > > > </div> > > > <div id="AMXJSPlayer_Programme"> > > > <p>Programme View</p> > > > </div> > > > <div id="AMXJSPlayer_List"> > > > <p>List View</p> > > > </div> > > > </body> > > > </html> > > > > > And here is the simple javascript i'm using in addition to > > > swfobject.js: > > > > > var FLASH_VERSION = "9.0.124"; > > > var DIV_IDS = new Array("AMXJSPlayer_Model", "AMXJSPlayer_Category", > > > "AMXJSPlayer_Meta", "AMXJSPlayer_Video", "AMXJSPlayer_Latest", > > > "AMXJSPlayer_Programme", "AMXJSPlayer_List"); > > > var moduleDivs = new Array(); > > > var moduleSwfs = new Array(); > > > > > if (swfobject.hasFlashPlayerVersion(FLASH_VERSION)) > > > { > > > swfobject.addDomLoadEvent(validateDivs);} > > > > > else > > > { > > > alert("No Flash Player or older version than is required!"); > > > > > } > > > > > function validateDivs() > > > { > > > for (var i=0; i<DIV_IDS.length; ++i) > > > { > > > var divId = DIV_IDS[i]; > > > var currentDiv = document.getElementById(divId); > > > if(currentDiv) > > > { > > > moduleDivs.push(currentDiv); > > > } > > > else > > > { > > > //no div available > > > } > > > } > > > for (var j=0; j<moduleDivs.length; ++j) > > > { > > > var validDiv = moduleDivs[j]; > > > initializeSwf(validDiv); > > > } > > > > > } > > > > > function initializeSwf(divId) > > > { > > > var divId = divId.id; > > > var swfName = divId+".swf"; > > > var properties = { data:swfName, width:"100", height:"100"}; > > > var parameters = { menu:"false" }; > > > var theSwf = swfobject.createSWF(properties, parameters, > divId); > > > moduleSwfs.push(theSwf); > > > > > } > > > > > At first i thought it might be my flex swfs, so i created a > > > framework.swz RSL...no difference. > > > Then i decided to remove any trace of Flex and just published > > > actionscript only swf's so file size went from 100800 bytes to 600 > > > bytes... still no difference > > > > > So it's defo something to do with swfobject. I also tried the static > > > embed approach but to be honest although it did work, it's a nightmare > > > to ensure our clients will copy the code exactly as required when > > > creating their own pages. Just adding a div with specific id to swap > > > out is the preferred option. > > > > > Anyone got any ideas what's happening in the background when i'm > > > calling 'createSwf' and is there any way to make things happen any > > > faster? > > > > > Cheers > > > Doug > > -- > You received this message because you are subscribed to the Google Groups > "SWFObject" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<swfobject%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/swfobject?hl=en. > > -- You received this message because you are subscribed to the Google Groups "SWFObject" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/swfobject?hl=en.
