documentcloud / jammit

Industrial Strength Asset Packaging for Rails
http://documentcloud.github.com/jammit/
MIT License
1.16k stars 197 forks source link

@media support? #26

Closed chriseppstein closed 14 years ago

chriseppstein commented 14 years ago

The CSS @media directive can be used to mark sections of the stylesheet for different media using media queries. An interesting idea would be to support including the print stylesheet in the "jammed" stylesheet by embedding it within @media print { ...content here... }.

The downside is that the content would not be conditionally downloaded in cases where the media query matches.

jashkenas commented 14 years ago

That's a neat idea, but I think you gave a really good reason not to do it. I don't know how smart browsers are about it these days, but they don't need to download the print stylesheet to render on the web, and we definitely shouldn't be including those styles in the CSS unless they need to be there. For the same reason, it's not recommended to embed images in your stylesheets that aren't visible immediately on page load.

If you'd like to mimic this using the current jammit, just define a package that includes both the screen and print stylesheets, where the contents of the source print stylesheet are wrapped in an @media print block.

Closing the ticket...