2010-07-09 66 views
0

我們在Websphere Portal Server上部署了幾個Portlet。在CSS文件中,我們包含了img標籤的行爲屬性。由於img行爲標記導致的多個HTTP請求

img { 
    position:relative; 
    border:none; 
    outline:none; 
    behavior: expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none", this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='image')", this.src = "transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("', '').replace('")', ''), this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "', sizingMethod='crop')", this.runtimeStyle.backgroundImage = "none")), this.pngSet=true)); 
} 

我們已經想通了,這種行爲標籤導致多次HTTP requests.In portlet的JSP中的一個,我們已經包括了樣式類,如下所示

<link rel="stylesheet" type="text/css" title="Style" 
    href=''<%=request.getContextPath()+"/theme/stylesheet.css" %>'> 

的問題是存在,只有當我們有那個request.getContextPath()。如果我用實際的上下文根替換它,它不會產生問題。有人能讓我知道爲什麼那個行爲屬性導致了這個問題嗎?

回答

1

Yahoo!有一篇標題爲的文章加快您的網站的最佳實踐。有一點需要避免的是CSS中的表達式,因爲它們的評估次數比預期的要多,只需移動鼠標或滾動頁面即可。

文章可以在這裏閱讀和查找標題避免CSS表達式

http://developer.yahoo.com/performance/rules.html

相關問題