How slow are CSS media-queries?

Tags: css,optimization,media-queries

Problem :

When I organize my CSS, I like to keep related styles altogether (header styles are in one section, footer styles are all in the same place, etc.) (sorry, OOCSS advocates).

I've recently been experimenting with media queries for smaller/larger screens. To keep with my organizational scheme, I would have to include separate queries for each screen size I'm targeting with each section of the code. (So, for example, if I was supporting, like, seven different screen sizes, I would have seven different media queries with my "header" CSS, and then seven queries in the "footer" section, etc.)

Leaving aside the question of whether or not this is how I should do it, are there any technical ramifications to having so many blocks of media queries? (They're all either min-width, max-width, or both. Say I had 100 different queries, but there are only seven distinct sizes I'm checking over and over again.) Would it take the browser longer to parse?

Solution :

The code handling potentially slow paths is heavily optimized in modern browsers, so you don't need to pre-optimize this kind of things unless you definitely have to, with the profiling data at hand. Go ahead and write it.

    CSS Howto..

    How to add circle shape to CSS button

    How to make responsive popup div?

    How to cut the bottom overflow of page CSS/HTML

    How to force inline-block wrap to new line using CSS or jQuery?

    How to make a div fill up remaining horizontal space

    How to apply css style to custom attributes

    How do I reduce the space between my menu titles and items?

    How to detect if my search bar has been expanded?

    How to use a Video as text background in css

    How do I apply (or edit) a broad set of styles to only one class/ID?

    How to make a ruler scale in HTML and CSS

    Fixed sidebar, content under it, how to fix?

    How do I apply css to second level menu items?

    How to fix the my Anchor link issue [duplicate]

    How to style Bootstrap menu like a V? [closed]

    How to change the size of an image inside a div without changing the div size

    How to add spacing between checkboxlist items?

    How to float elements to the center in CSS?

    text-align:center doesn't work vertically in CSS, how can I get around this?

    How can I apply an existing CSS class style to a dynamically created div?

    How to save game information PHP/HTML/CSS/JS [closed]

    How to hide specific lines of css from IE 7 and IE 8

    How to achieve the following navigation with CSS and HTML

    How to use “Wedding text ” in Css font family?

    How to include css in mulitple jsps?

    how do I apply a class to the header cell for a column in slickgrid

    How to style a video iFrame?

    How to remove extra space under paragraph in HTML/CSS

    IBM Worklight - How to disable Native device features?

    How to get rid of this whitespace in internet explorer?