Re: [Bulk] Re: @import -- allow at any place in stylesheet.

There are different situations: internet, intRAnet, local webpages opened from CD. Delay concern is applicable to former one only. Moreover, nested @imports are allowed and used, though they cause same delays.

Anyway, such arguments are somewhat about best practices, but unlikely was actual reason (and unlikely should be a reason) to disallow @imports after rules on syntax level.


17.01.2012, 20:53, "François REMY" <fremycompany_pub@yahoo.fr>:
> As a side note, it's also an optimization. As soon as the CSS file is
> received, the browser can know if there will be additionnal files to
> download. The more at the top the url is, the more quickly the new download
> can start. Also, the browser know at the first non-@import rule that he
> don't need to download new (css) files. This can help to make decisions for
> questions like "do I need to keep that TCP connection open?".
>
> Sometimes, enforcing rules is better than try to get people writing good
> code. It may be the case here.
>
> Regards,
> François
>
> -----Message d'origine-----
> From: Tab Atkins Jr.
> Sent: Tuesday, January 17, 2012 5:14 PM
> To: Marat Tanalin | tanalin.com
> Cc: www-style@w3.org
> Subject: [Bulk] Re: @import -- allow at any place in stylesheet.
>
> On Mon, Jan 16, 2012 at 7:36 AM, Marat Tanalin | tanalin.com
> <mtanalin@yandex.ru> wrote:
>
>>  Hello. It makes sense to allow @import at any place in CSS stylesheet.
>>
>>  For example, if we have:
>>
>>     .rule-before-example {...}
>>     .example {...}
>>     .rule-after-example {...}
>>
>>  We could have same expressed with @import:
>>
>>     @import "before-example.css";
>>     .example {...}
>>     @import "after-example.css";
>>
>>  where "after-example.css" contains:
>>
>>     .rule-after-example {...}
>>
>>  (Real-world imported stylesheets are, of course, much larger.)
>>
>>  So why should @import be disallowed here for importing
>>  "after-example.css"? This just makes development less usable/flexible.
>
> What does this help with?
>
> The restriction that @import has to appear at the top of a file is
> meant, I believe, to make it easier to understand that other files are
> being imported.  A lone @import in the middle of a file is easy to
> accidentally skip over for a human.
>
> Note that if you really want to interleave some imported code, you can
> do so by just using *more* imports, like:
>
> ---top of file---
> @import "before-example.css";
> @import "example.css";
> @import "after-example.css";
>
> ~TJ

Received on Tuesday, 17 January 2012 17:19:52 UTC