IEã§@importã«ã¼ã«ã使ãéã®ãã¡ãªãã2ç¹
追è¨
2008.11.12å°ãæ´æ°ãæ´çãããå°ãæ¤è¨¼ãããåé¿å¯è½ãªãã¡ãªãããªæ°ããã¦ããã
ã¯ããã«
CSSããã¯ã®è©±ã§ã¯ãªãèªåã§æ¤è¨¼ã»è¿½è©¦ããããã§ã¯ãªã
ï¼CSSã®ã°ã«ã§ããï¼Ericãããè¨ã£ã¦ãã»ã»ã»ãã¨ï¼JS/DOMã®ã°ã«ã§ããï¼Jeremyãæ¸ãã¦ãã¨ããä¼è
@importã«ã¼ã«ã使ãéã®ãã¡ãªãã
- @importã使ã£ã¦ãªã³ã¯ãããcssãã¡ã¤ã«ã¯ãIEã§ã¯ãã£ãã·ã¥ãããªãããã¼ã¸ç§»åãããã³ã«åèªã¿è¾¼ã¿ãããã¨ããç¹ã§ã転ééãã¼ã¿éãç¡é§ã«å¢ãã¦ããã©ã¼ãã³ã¹ãä½ä¸ãããç¡é§ãªhttpãªã¯ã¨ã¹ãã®çºçã
- styleè¦ç´ ãç¨ãã¦ã@importã§cssãã¡ã¤ã«ãèªã¿è¾¼ãã¨ãããã¼ã¸ã®æ«å°¾ï¼</body>ã®è¿ãï¼ããlinkè¦ç´ ã§cssãã¡ã¤ã«ã®èªã¿è¾¼ã¿ããã¦ãããã®ãããªåä½ãIEã¯ãã¦ãã¾ãããã®ãããCSSã®ã¬ã³ããªã³ã°ãé ãããä¾ãã°ãããããFOUC(Flash of Unstyled Content)ã®åå ã«ãªãã
ï¼ç¹ç®ã¯ãlinkè¦ç´ ï¼@importãã§ã¯ãªããstyleè¦ç´ ï¼@importãã§çºçããåé¡ã
<style type="text/css" media="screen">@import "style.css";</style>
import.cssã®ãããªCSSãã¡ã¤ã«ã®ä¸ã§@importãè¨è¿°ãã¦ãã¡ã¤ã«èªã¿è¾¼ã¿ããå ´åã«ã¤ãã¦ã¯è§¦ãã¦ããªãã
@importã¯CSSã®ã¡ã³ããã³ã¹ã§ã¯è¯ãããææ³ãã ãã©ãä¸è¨ã®ãã¡ãªãããäºå®ãªãã°ã念é ã«ç½®ãã¦ã©ã¼ããã決ãããåé¿æ¹æ³ãæ¢ãããã¬ã¼ããªããèªèãã¦é¸æãããetc..
IEã§ãã£ãã·ã¥ãããªãåé¡
å ¸æ- //adactio.com/journal/1498" target="_blank">The Lessons of CSS Frameworks:Jeremyã«ããAn Event Apart Chicago 2008ã®ã©ã¤ããã°ã
Some of the frameworks have a single short style sheet that you point to from your markup, which then links off to separate style sheets for fonts, colours, layout, etc. But most of them use separate style sheets and you must link to each one in your markup. Eric reckons that this is because IE for Windows will cache the first style sheet you point to with a link element but not any subsequent style sheets with @import.
- //www.scribblelive.com/Event/An_Event_Apart_San_Francisco?Page=1#LiveBlog_Post22973" target="_blank">An Event Apart San Francisco...live blogging:åããAn Event Apart Chicago 2008ã®ã©ã¤ããã°ãJeremyãããè¶ è©³ããçã
IE/Win only caches the first css file when you use @import (the WIRED method) rather than the 'standard' linking method. I've never dealt with that because: a) never dealt with a site crazy enough to really worry to much about server performance, and b) I've never really used the @import method. :)
äºã¤ã¨ã話ã®åºæã¯ãAn Event Apart Chicago 2008ã§ã®Eric Meyerã®ãã¬ã¼ã³ãThe Lessons of CSS Frameworksãã«è¡ãçãã
Eric以å¤ã«ãã®åé¡ãææãã¦ãã人ã¯èªåã¯è¦ã¤ãã¦ããªãã
linkè¦ç´ ã§èªã¿è¾¼ã¾ããcssãã¡ã¤ã«ã¯ãã£ãã·ã¥ãããããã®cssãã¡ã¤ã«ãã@importã使ã£ã¦èªã¿è¾¼ã¾ããcssãã¡ã¤ã«ï¼subsequent style sheetsï¼ã¯ãã£ãã·ã¥ãããªããã¨è¨ã£ã¦ãã模æ§ã
IEã§ãã£ãã·ã¥ãããªãåé¡ãåé¿ããã«ã¯
解決æ¹æ³ã¯è¦ã¤ãã¦ãªããã¨ããããã®åé¡ãåç¾ã§ããªãã@importã«ã¼ã«ã§è¤æ°ã®cssãã¡ã¤ã«ã«ãªã³ã¯ãã¦ããcssãã¡ã¤ã«ãlinkè¦ç´ ã§èªã¿è¾¼ãã§ããµã¤ããIEã§è¦ã¦ãããã¨ããã§ãã¯ãããã©åé¡ãªããã£ãã·ã¥ããã¦ããã
>@importã使ãã¨cssãã¡ã¤ã«èªã¿è¾¼ã¿ãå¾åãã«ãªãåé¡
å ¸æ ã¯Yahoo! Developer Networkã®æåãªè¨äºã- //developer.yahoo.com/performance/rules.html#csslink" target="_blank">Best Practices for Speeding Up Your Web Site:ãã®è¨äºèªä½ã¯ã¦ã§ããµã¤ãã®ããã©ã¼ãã³ã¹ãã¥ã¼ãã³ã°ã®ããã®34ã®ãã¹ããã©ã¯ãã£ã¹ããããããã®ãCSSã«ã¤ãã¦æ¸ããã¦ãã®ã¯ãã®ãã¡ï¼~ï¼åã
One of the previous best practices states that CSS should be at the top in order to allow for progressive rendering.
In IE @import behaves the same as using at the bottom of the page, so it's best not to use it.
- //www.bluerobot.com/web/css/fouc.asp/" target="_blank">Flash of Unstyled Content (FOUC):FOUCã®ç´¹ä»è¨äºãFOUCã®ä½é¨æ¹æ³ï¼IE5以ä¸ãç¨æãã¾ãããããã£ãã·ã¥ã¯ã¯ãªã¢ãã¾ããããã»ã»ã»çã ï¼ããã解決æ¹æ³ã¾ã§ã
解決ã®æ¹åã¯ï¼éããstyleè¦ç´ ï¼ï¼@importï¼ã使ç¨ãã¤ã¤åé¿ãç®æãããstyleè¦ç´ ã¯ä½¿ããã«åé¿ãç®æããã
styleè¦ç´ ã¨@importã¯ä½¿ããããåé¡ã¯è§£æ±ºãããå ´å
ä¸è¿°ã®Flash of Unstyled Content (FOUC)ã«ã¦ç´¹ä»ããã¦ãã- åé¡ã«ãªãstyleè¦ç´ ã®ä¸ã«linkè¦ç´ ãç½®ãï¼å°å·ç¨ã®cssãã¡ã¤ã«ã¸ã®ãªã³ã¯ãªã©ï¼
- åé¡ã«ãªãstyleè¦ç´ ã«ä¸ã«ç©ºã®scriptè¦ç´ ãç½®ã
ãã®è§£æ±ºæ¹æ³ã®åé¡ç¹ã¨ãã¦ãææ¸ä¸å¿ è¦ãªlinkè¦ç´ ãç½®ããªãå ´åãããç¹ãä¸è¦ãªscriptè¦ç´ ãç½®ãç¹ã