Ben Dill's Blog

IE Image Bug = Website Performance Hit

While troubleshooting a site I'm developing, I noticed that a page was double posting.  After a little brute force diagnostics, (comment everything out, bring things in one-at-a-time), I was able to isolate the issue.

My company has a couple of ImageButtons that are wired up as hover buttons.  We have a control that you set the on & off images on and it does the rest.  For some reason (Murphy's Law I suppose), we weren't sending out the ImageButton's ImageUrl as the off image.  We just let the startup javascript assign that client side.  This resulted in an input type=image form field with an empty src attribute being sent to the client.  That seems benign right?  Well it isn't...

If you have on your page one image field with a valid src attribute and another with no src attribute, IE interepts the src of the missing attribute to be the url of the current page and then IE will proceed to request the current page again in hopes of displaying an image for the missing scr attribute.  Ouch right?

This means that if you have any control, image button, asp:image, etc on you site that is sending out src="", which you might not, IE will perform a double post to your page.  Yes a double post and all form fields are sent, it is a full blown duplicate request.  This means performance * .5...

This is easily tested in your ASP.NET application.  All you need is a page with the following markup and a wired up Page_Load with a breakpoint on string Foo = "Bar";.  Run the debugger an enjoy...

<img src="" /><img src="valid.jpg" />

Disclamier:  I haven't tested to see if the non-blank src must be valid...  When I say IE I have only tested IE7 and it fails.  I did test Google Chrome and it did not create a duplicate request.

I realize that this might not be a big deal because I'm the only person out there sending out empty src attributes, but I thought I'd share the find.

Posted: Jan 25 2009, 09:10 PM by MuteThis | with 6 comment(s)
Filed under:

Comments

anonymous said:

Alternatively , you could try :

# January 25, 2009 11:51 PM

John Katsiotis said:

Thanks for pointing it out!

The same thing also happens at Firefox...

# January 26, 2009 2:56 AM

webbes said:

You could enter a non existing uri and use fe. jQuery to remove the src attribute. The behavior is gone if you do it like this...

Cheers,

Wes

# January 27, 2009 5:16 AM

برای رضای خدا Internet Explorer را رها کنید | ايران گت :: IranGet said:

Pingback from  برای رضای خدا Internet Explorer را رها کنید | ايران گت :: IranGet

# February 4, 2009 5:59 PM

ie img src=””??????_????????????_??????_javascript_ php_css said:

Pingback from  ie img src=&#8221;&#8221;??????_????????????_??????_javascript_ php_css

# September 6, 2009 9:55 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)