Hi Kyle Thanks.
I didn't do tons of testing with this particular code example, but I've used this approach for dynamically adding a script element many times, and it's always worked for me regardless of when other scripts and the window.onload event has fired. It's basically a home-brewed lazy loading system. Any script element that gets added to the DOM should fire immediately. Of course, I'd love to hear what you and anyone else encounters in their own testing. :) - philip On Mon, Feb 9, 2009 at 5:05 AM, Getify Solutions, Inc. <[email protected]>wrote: > Philip- > That looks really good. I'm sure this is gonna be really useful going > forward as a great FAQ item and help to people. > > I have a question... have you tested what happens if this code *runs* after > the page was already loaded and running? In other words, does your code > block's logic work the same if someone chooses to embed their swf (and also > initiate the google tracking) not DURING page load, but sometime well after > it? > > The use case I'm thinking of is where a set of code (such as yours) is > dynamically added to a page at some later run-time point, where the page's > "onload" (and indeed any domload's) have certainly already fired. This is a > common thing for CMS's and other such systems to defer and run/add > javascript to pages on-the-fly. > > What I'm mostly wondering is, does the logic of detecting a script-tag > completion in the way that you do work in that use case? At one time I had > toyed with trying to directly detect script tag loading completion like that > and had some trouble if the script tags were added to a page after its > normal onload/domready's had passed. But perhaps I was just doing it > wrong! I just wanted to see if you've tested it in that way, because > perhaps it's a case we might want to consider if not. And if it *does* > work, then I'm excited because I can update (and simplify) some of my own > code using that technique! > > Thanks again for this script block. I'm sure it'll be very useful and > helpful! > > --Kyle > > > > > *From:* Philip Hutchison <[email protected]> > *Sent:* Monday, February 09, 2009 2:46 AM > *To:* SWFObject <[email protected]> > *Subject:* SWFObject & Google Analytics > > Just an FYI: I've written some code that enables SWFObject users to move > the Google Analytics code out of their markup and place it in a domready > event where it belongs. This may help some users with their SWF load time > (removing the analytics code from the markup means dynamically embedded SWFs > won't have to wait for the Google code to load first). > > You can read the write-up and see an example here: > http://pipwerks.com/lab/swfobject/google-analytics/index.html > > Comments/suggestion welcome. > > - philip > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
