Hi. Can someone tell me what's the deal with common.css nowadays? Does it get loaded automatically now, or do we still need to import it manually? Regards
Hi. Can someone tell me what's the deal with common.css nowadays? Does it get loaded automatically now, or do we still need to import it manually? Regards
Ok, thanks everyone.
It's a truism of the community forums that the respondents don't know how much the original poster knows, and the original posters often don't ask precisely the question they mean to ask. it usually saves time to give a full answer to begin with. That said, I did directly answer your questions, both the broader, "So what's the deal with Common.css nowadays?" and the narrower, "Does common.css need to be imported manually?"
CzechOut wrote: So if you want to share CSS between the two skins, you do need to manually import it.
...
Correction to this, Common.css is automatically imported in Monobook but not Oasis. In Monobook, the site script controller takes Common.css and Monobook.css and mashes them together. This causes problems since @import
directives in Monobook.css don't work at all (@import
must be at the start of a CSS file, but ResourceLoader grabs Common.css then glues Monobook.css onto the end of it so any @import
in Monobook are actually in the middle of the two files which means they won't work).
Oasis' script controller only grabs Wikia.css without touching Common.css; as such, @import
does work properly in Wikia.css at the price of Common.css having to be imported manually.
Okay, yeah, now that you're saying that Common is automatically imported into Monobook, I remember that as being true. But you can't use @import at all in Monobook? Why would the fact that any @imports would be in the middle of the Monobook and Common matter? Why does order of CSS have any impact on its functionality, except in those cases of a later statement directly disputing an earlier one?
Oh, wait. You're saying that @import must be at the beginning of the file, and it can't be at the beginning of the file, right? Well what about that new way of doing imports? That doesn't have to be at the beginning of a file, right?
@import statements must be at the very beginning of the file:
CSS 2.1 user agents must ignore any '@import' rule that occurs inside a block or after any non-ignored statement other than an @charset or an @import rule.
quote from CSS 2.1 spec
Gotcha, but couldn't you push css imports to Monobook via the method described at help:including additional JavaScript and CSS — i.e. the importArticle way?
The ResoureLoader has nothing to do with it. If you use an @import statement with a ResourceLoader URL then the standard CSS restrictions apply. If you use the ResourceLoader to load stylesheets via JavaScript then you effectively create a new style-tag that contains the imported styles and nothing but. The restrictions of @import statements don't apply in that case.
(Unless of course that stylesheet you import with JS contains @import rules...)