TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Don’t use @import

75 点作者 mcxx大约 16 年前

5 条评论

scorxn大约 16 年前
Or more succinctly: "In IE @import behaves the same as using &#60;link&#62; at the bottom of the page, so it's best not to use it." Know and love <a href="http://developer.yahoo.com/performance/rules.html" rel="nofollow">http://developer.yahoo.com/performance/rules.html</a>
nihilocrat大约 16 年前
I wasn't even aware @import existed, and I don't really see any redeeming reasons to use it instead of 'link' anyways, as 'link' is "cleaner" and is HTML and thus can reap all the rewards that linked javascript, image links, etc. enjoy. Can someone please explain?
评论 #560692 未加载
评论 #560016 未加载
评论 #560098 未加载
评论 #560022 未加载
mr_justin大约 16 年前
I highly recommend his book (or wait for the upcoming 2nd edition), it is filled with invaluable stuff like this. Really an eye opener for me.
Alex3917大约 16 年前
Speaking of, is there a way to import the navigation menu into an xhtml page without php or somesuch? Both "link" and @import are only valid within the header, so they are no good for importing data into the body of the page.
评论 #559836 未加载
评论 #559873 未加载
tremendo大约 16 年前
The original rationale for using @import for including a CSS file in HTML was that Netscape Navigator 4 did not understand the command and thus was an easy, effective and compliant way to exclude that browser, since it had atrocious support for stylesheets. Now that NN is no longer a factor it makes sense to relegate the use of @import to only within a CSS file. BWT, the screen flicker of IE is eliminated if LINK is used first (say to load a reset.css file) and any subsequent stylesheet loaded via @import behaves as it should.