fullcatrooms / swfobject

Automatically exported from code.google.com/p/swfobject
0 stars 0 forks source link

Flash remains hidden when using static publishing and placing scripts at the bottom of the page #336

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add a flash object using static publishing
2. Place the script tag with the registerObject method at the bottom of the
page (just before closing the body tag)

What is the expected output? What do you see instead?
Expected: object tag with visibility: visible
Actual output: object tag with visibility: hidden

What version of the product are you using? On what operating system?
swfobject 2.2, Firefox 3.5. Page is rendered in Standards mode, XHTML 1.0
Strict and contains no invalid code.
It usually works fine in IE8, Chrome 3 and Safari 4, but fails every now
and then. I remember that IE7 usually failed; however I'm unable to test in
that browser at the moment.

Please provide any additional information below.

Placing scripts at the bottom of the page is a popular method of speeding
up page rendering, recommended by Steve Souders (previously of Yahoo,
currently at Google). Read more about it here:
http://developer.yahoo.net/blog/archives/2007/07/high_performanc_5.html

It would be great if it was possible to get the benefits of static
publishing as well as the performance benefits of placing scripts at the
bottom of the page.

Original issue reported on code.google.com by lunde...@gmail.com on 2 Jul 2009 at 10:15

GoogleCodeExporter commented 9 years ago
Well, that's not how SWFObject works. It contains a DOM independent and a DOM
dependent part, so when you define all your scripts in the header of your Web 
page it
immediately executes the DOM independent code, and adds the DOM dependent part 
as
soon as the DOM of a page is available, via the DomContentLoaded event or a
simulation of it if the browser doesn't support it.

The link you refer to is an old workaround that dates before the time of the
DomContentLoaded event and a bad practice IMO. It also performs worse, because 
the
DOM independent part is only executed at the end of the page. Furthermore just 
Google
for "unobtrusive JavaScript" to see what the advantages of this approach is.

So either use SWFObject as intended or - worse - include your scripts at the 
top of
your body before the actual object elements that embed your Flash content. 

Original comment by bobbyvandersluis on 2 Jul 2009 at 3:40

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
It's my understanding that Unobtrusive JavaScript is a technique to promote
separation of concerns (separation of behavior from presentation), not requiring
where a <script /> tag must reside. Placing your JavaScript code in a file 
promotes
SoC, but requiring the <script /> tag to be placed in the <head /> of a document
doesn't really ensure SoC, IMO :)

My main concern with this implementation is that this requires a workaround for
ASP.NET AJAX developers when using an ASP.NET ScriptManager control. The
ScriptManager control manages script file registrations on the Page, as well as 
any
other control using a ScriptManagerProxy. Script registrations are then placed 
before
any content on the page (immediately following the <body> tag), but yet they are
not in the <head /> tag. That being said, ASP.NET AJAX developers using the
ScriptManager control (which nearly all do) cannot use SwfObject for static
publishing with this implementation. I will modify my GdnSwfObject server 
control to
fix this issue, but I wanted to bring this limitation to your attention.

I'd also like to note that I've only been able to reproduce the issue using 
Firefox
3+ and static publishing. With that said, the <script /> reference to 
swfobject.js is
placed before the <object /> tag. Thoughts?

Thanks, Bobby!

Original comment by grant.ha...@gmail.com on 5 Oct 2009 at 9:41