OPTIMIZING MEDIA QUERIES Responsive Web Design Summit, April 16, 2013

Kimberly Blessing @obiwankimberly Director, Think Brownstone Philadelphia, PA

DOES THE WAY WE WRITE MEDIA QUERIES IMPACT PAGE PERFORMANCE? WHICH TECHNIQUE YIELDS THE BEST PERFORMANCE?

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

PART 1: TEST MEDIA QUERY SPECIFICITY Media queries that use cascading expressions

VS

Media queries bound to specific screen sizes

@media screen and (min-width: 600px) { body {color:black} }

@media screen and (min-width: 600px) and (max-width: 767px) { body {color:black} }

@media screen and (min-width: 768px) { body {margin:1em} }

@media screen and (min-width: 768px) and (max-width: 974px) { body {color:black; margin:1em} }

@media screen and (min-width: 975px) { body {background:url(…)} }

@media screen and (min-width: 975px) { body {color:black; margin:1em; background:url(…)} }

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

3

PART 2: TEST CODE STRUCTURE @media blocks consolidated at end

VS

@media blocks interspersed throughout

/* All CSS rules for MVP/LCD */

/* Component CSS for MVP/LCD */

@media screen and … { /* All for “tablet” */ }

@media screen and … { /* Component for “tablet” */ }

@media screen and … { /* All for “desktop” */ }

xN

@media screen and … { /* Component for “desktop” */ }

MVP = minimum viable product LCD = lowest common denominator

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

4

THE TEST SUBJECT: WEBLINC.COM •

Responsive design with three breakpoints, but no responsive images



All tests run against production hardware, which is CDN-fronted and runs mod_pagespeed



Tests run on Saturdays and Sundays around 3 AM (minimal traffic/load)



Copies of test files and data available at http://presentations.kimberlyblessing .com/2012/cssdevconf/

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

5

TESTING METHODOLOGY Test Scenarios

Data Collection

1.

CSS with no media queries (MVP/LCD)

• File size and code complexity metrics

2.

Cascading media queries consolidated at end

3.

Cascading media queries interspersed throughout

• CSS profiling statistics, collected using Opera’s Developer Tools

4.

Targeted screen size media queries consolidated at end

5.

Targeted screen size media queries interspersed throughout

• Page load times for home page (first and repeat views) on major desktop browsers and iPhone, collected with WebPageTest

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

6

FILE SIZE AND CODE COMPLEXITY Minified (bytes)

Min + GZIP (bytes)

# MQs applied

# MQs

# CSS rules applied

No MQs

22,226

5,467

0

0

251

Cascade/End

43,694

9,954

8

4

485

Cascade/Inter

44,434

9,298

28

21

485

Targeted/End

53,221

10,107

8

2

445

Targeted/Inter

54,152

9,477

29

13

445

* Number of media queries/rules applied at 1024px screen width

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

7

CSS PROFILING STATISTICS CSS Parsing

Style Recalculation

Reflow

Layout

Paint

No MQs

6.0

2.2

13.4

9.6

224.2

Cascade/End

8.0

3.8

17.6

16.8

237.0

Cascade/Inter

9.4

3.2

18.4

17.6

252.0

Targeted/End

9.6

2.8

16.8

17.2

256.8

Targeted/Inter

9.6

3.0

20.2

17.4

251.2

* Times in milliseconds Average of 5 test runs using Opera Developer Tools

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

8

PAGE LOAD TIMES* (FIRST VIEW) IE 8

IE 9

IE 10

Firefox

Chrome

iPhone

No MQs

1.1

0.9

1.0

1.8

1.0

3.5

Cascade/End

1.0

0.8

1.0

1.9

1.2

4.8

Cascade/Inter

1.1

1.0

1.0

2.1

1.2

4.5

Targeted/End

1.2

1.3

1.0

1.9

1.1

4.7

Targeted/Inter

1.4

0.9

1.0

2.0

1.2

4.6

* Times in seconds Average of 10 test runs with WebPageTest. Outliers have been removed.

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

9

PAGE LOAD TIMES (FIRST VIEW) 5 4.5 4 3.5 3 2.5 2 1.5 1 0.5 0

Cascade/End Cascade/Inter Targeted/End Targeted/Inter

IE8

IE9

IE10

Firefox Chrome iPhone

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

10

PAGE LOAD TIMES* (REPEAT VIEW) IE 8

IE 9

IE 10

Firefox

Chrome

iPhone

No MQs

0.5

0.3

0.3

1.4

0.4

1.4

Cascade/End

0.5

0.3

0.3

1.4

0.5

1.7

Cascade/Inter

0.5

0.3

0.3

1.5

0.5

1.6

Targeted/End

0.6

0.4

0.3

1.3

0.4

1.7

Targeted/Inter

0.5

0.3

0.3

1.5

0.5

1.6

* Times in seconds Average of 10 test runs with WebPageTest. Outliers have been removed.

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

11

PAGE LOAD TIMES (REPEAT VIEW) 2.0

1.5 Cascade/End Cascade/Inter Targeted/End Targeted/Inter

1.0

0.5

0.0 IE8

IE9

IE10

Firefox Chrome iPhone

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

12

ANOTHER TEST: MICROSOFT.COM •

Responsive design with six(-ish) breakpoints and responsive images



Tests run from my personal server with mod_pagespeed



Tests run on a Saturday night while watching Doctor Who



Copies of test files and data available at http://presentations.kimberlyblessi ng.com/2013/rwdsummit/

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

13

PAGE LOAD TIMES* (FIRST VIEW) IE 8

IE 9

IE 10

Firefox

Chrome

iPhone

Android

No MQs

4.4

4.0

2.6

2.8

2.8

13.7

15.2

Cascade/End

4.5

4.3

2.6

3.6

3.6

12.8

12.6

Cascade/Inter

4.2

3.7

2.7

3.5

3.5

13.1

13.7

Targeted/End

5.2

4.6

2.6

4.0

3.4

12.4

12.7

Targeted/Inter

4.6

4.0

2.7

3.5

3.0

12.6

13.5

* Times in seconds Average of 10 test runs with WebPageTest. Outliers have been removed.

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

14

PAGE LOAD TIMES (FIRST VIEW) 14 12 10 8

Cascade/End Cascade/Inter Targeted/End Targeted/Inter

6 4 2 0

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

15

PAGE LOAD TIMES* (REPEAT VIEW) IE 8

IE 9

IE 10

Firefox

Chrome

iPhone

Android

No MQs

1.4

1.3

0.9

1.6

1.1

5.4

9.4

Cascade/End

1.3

1.3

0.8

1.6

1.2

5.5

8.7

Cascade/Inter

1.3

1.3

0.9

1.6

1.3

5.6

8.5

Targeted/End

1.6

1.3

0.9

1.8

1.4

5.5

9.0

Targeted/Inter

1.4

1.4

0.9

1.5

1.2

5.6

8.5

* Times in seconds Average of 10 test runs with WebPageTest. Outliers have been removed.

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

16

PAGE LOAD TIMES (REPEAT VIEW) 10 9 8 7 6 5 4 3 2 1 0

Cascade/End Cascade/Inter Targeted/End Targeted/Inter

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

17

DOES THE WAY WE WRITE MEDIA QUERIES IMPACT PAGE PERFORMANCE? WHICH TECHNIQUE YIELDS THE BEST PERFORMANCE?

YES, media query syntax and code structure have an impact on performance… …however no particular technique stands as performance silver bullet. Writing optimized CSS overall is best!

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

CSS OPTIMIZATION RECOMMENDATIONS Understand any resets and frameworks you use. Trim unused code and rewrite inefficient selectors or declarations. Schedule periodic code reviews to prune unused code, based both on old content and old browsers. Reevaluate your browser support matrix. Limit the use of browser hacks, polyfills, and prefixed properties. Profile CSS selectors and optimize for right-to-left parsing. Regularly test site performance, compare data before and after code changes to understand impact

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

19

REQUIRED READING Reflows & Repaints: CSS Performance making your JavaScript slow? by stubbornella (Nicole Sullivan) http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performancemaking-your-javascript-slow/

Profiling CSS for fun and profit. Optimization notes. by kangax (Juriy Zaytsev) http://perfectionkills.com/profiling-css-for-fun-and-profit-optimization-notes/

Real World RWD Performance by Guy Podjarny

http://www.guypo.com/uncategorized/real-world-rwd-performance-take-2/

And… follow updates from O’Reilly’s Velocity Web Performance and Operations Conference http://velocityconf.com/

Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

20

OPTIMIZING MEDIA QUERIES Optimizing Media Queries by @obiwankimberly, Responsive Web Design Summit, April 16, 2013

Kimberly Blessing @obiwankimberly www.kimberlyblessing.com

optimizing media queries - Presentations by Kimberly Blessing

Apr 16, 2013 - 10. Optimizing Media Queries by @obiwankimberly, Responsive Web ... IE 8. IE 9. IE 10. Firefox. Chrome. iPhone. Android. No MQs. 4.4. 4.0.

535KB Sizes 1 Downloads 244 Views

Recommend Documents

Viewport and Media Queries
Nevermind the pixels, here comes the Complete Idiot's Guide to. Viewport and ... If you want to have a CSS style that only smartphones will pick up, use: @media ...

Optimizing View Queries in ROLEX to Support ...
ware for business hubs, supply-chain integration, and cata- log management all ... application cache is undesirable for a number of reasons. First, multiple .... If this fraction is small, the optimizer might choose to implement the query ...... the

pdf-146\french-verb-conjugations-by-kimberly-r ...
pdf-146\french-verb-conjugations-by-kimberly-r-norton.pdf. pdf-146\french-verb-conjugations-by-kimberly-r-norton.pdf. Open. Extract. Open with. Sign In.

pdf-1457\jew-among-jews-rehabilitating-paul-by-kimberly-ambrose ...
pdf-1457\jew-among-jews-rehabilitating-paul-by-kimberly-ambrose.pdf. pdf-1457\jew-among-jews-rehabilitating-paul-by-kimberly-ambrose.pdf. Open. Extract.

SQL SERVER INTERVIEW QUESTIONS QUERIES By Vikas ...
Page 3 of 34. SQL SERVER INTERVIEW QUESTIONS QUERIES By Vikas Ahlawat.pdf. SQL SERVER INTERVIEW QUESTIONS QUERIES By Vikas Ahlawat.pdf.

SQL SERVER INTERVIEW QUESTIONS QUERIES By Vikas ...
--ANS: SELECT * FROM [EmployeeDetail] WHERE FirstName like '[a-p]%'. Page 3 of 34. SQL SERVER INTERVIEW QUESTIONS QUERIES By Vikas Ahlawat.pdf. SQL SERVER INTERVIEW QUESTIONS QUERIES By Vikas Ahlawat.pdf. Open. Extract. Open with. Sign In. Main menu.

Semantic Queries by Example - Semantic Scholar
Mar 18, 2013 - a novel method to support semantic queries in relational databases with ease. Instead of casting ontology into rela- tional form and creating new language constructs to express ...... uni-karlsruhe.de/index_ob.html. [19] OTK ...

kimberly kane vivid.pdf
BACA: NU Berharap..., hal 7. KARANGANYAR-Rom- bongan wisata guru dan. keluarganya dari SDN Jim- baran Wetan, Kec Wonoayu,. Kab Sidoarjo, Jatim, berubah .... a problem loading this page. Retrying... Whoops! There was a problem loading this page. Retry

Semantic Queries by Example - Semantic Scholar
Mar 18, 2013 - Finally, we apply the query semantics on the data to ..... mantic queries involving the ontology data are usually hard ...... file from and to disk.

pdf-414\the-taking-by-kimberly-derting.pdf
Nevertheless, the exciting plot zips along, leaving readers impatiently waiting for the next. installment.—Sharon Rawlins, New Jersey State Library, Trenton.

Read PDF Beautiful Bodies By Kimberly Rae Miller
... ,epub 3 Beautiful Bodies ,calibre ebook management Beautiful Bodies ,epub ... Bodies ,how to open epub files Beautiful Bodies ,cool reader app Beautiful ...

pdf-2335\stolen-woman-stolen-series-by-kimberly ...
... Association of Baptists, Bangladesh. --a beautiful story of hope amidst a landscape of brokenness. Chad Salstom, Origin Coffee and Tea, where all profits go to rescuing the trafficked. Page 3 of 19. pdf-2335\stolen-woman-stolen-series-by-kimberly

School Blessing and Dedication Ceremony ... Accounts
theme. **NOTE: It is important that the parish priest be consulted concerning the liturgy​. There are several different ways in which to conduct the school.

Create-A-Blessing Loyalty Rewards
Earn 10 butterflies and submit your butterfly reward order by e-mailing me. ([email protected]) your Create-A-Blessing Butterfly Tracking Sheet or by clicking · here. Hostess stamps are excluded. •. I'll confirm your qualifying customer o

Presentations- Introducing Yourself - UsingEnglish.com
Microsoft Office XL. Office furniture. Roller skating. Seattle. Shaking hands. Socks. Spain. The 18th century. The London Underground The most recent elections. The year 2015. Starbucks. Wearable computers. Weight training. Work/ Life balance. Yugosl

Blessing-Mix-Printable.pdf
Candy Corn represent the sacrifices of the Pilgrim's first winter. Food was ... A Hershey's Kiss reminds us of the love of family and friends that sweetens our lives.

Kimberly Derting - 1. Eskü.pdf
Page 3 of 200. Kimberly Derting - 1. Eskü.pdf. Kimberly Derting - 1. Eskü.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying Kimberly Derting - 1.

Kimberly Derting - 1. Eskü.pdf
Nama sumber data atau informan dalam penelitian kualitatif, tidak boleh ..... Kimberly Derting - 1. Eskü.pdf. Kimberly Derting - 1. Eskü.pdf. Open. Extract.

author queries
8 Sep 2008 - Email: [email protected]. 22. ... life and domain satisfaction: to do well from one's own point of view is to believe that one's life is ..... among my goals. I also value positive hedonic experience, but in this particular. 235 situ