DEV Community

Daniel Pertu
Daniel Pertu

Posted on

Five Tailwind breakpoints ship in our CSS, two of them do all the work, and one changes nothing at all

Responsive design is usually discussed as a design decision and shipped as a pile of sm: and lg: prefixes nobody audits afterwards. I wanted the audit: how many media queries does our stylesheet contain, how many of them ever fire on a real page, and how much changes when they do.

The subject is Nakodo, 76 public pages served by Next 16, styled with Tailwind v4, 154,378 bytes of CSS in two files.

Every media query in the stylesheet

Pulling the CSS and brace-matching each @media gives 41 top-level blocks (one more is nested inside another) holding 22,155 bytes, which is 14.4% of the stylesheet:

Condition Blocks Rules Bytes
(min-width:40rem) = sm, 640px 3 138 7,755
(min-width:64rem) = lg, 1024px 2 55 3,128
(min-width:48rem) = md, 768px 2 27 1,352
(min-width:80rem) = xl, 1280px 2 5 174
(min-width:96rem) = 2xl, 1536px 1 1 27
(min-width:420px) 1 1 74
(min-width:360px) 1 1 48
not all and (min-width:40rem) = max-sm 1 4 137
not all and (min-width:64rem) = max-lg 1 1 29
(hover:hover) 8 49 4,492
(prefers-reduced-motion:no-preference) 10 45 4,130
(prefers-reduced-motion:reduce) 3 4 310
(forced-colors:active) 6 6 499

Two things stand out before any page is loaded. The sm blocks are 45 times the size of the xl blocks, and the entire 2xl breakpoint is this:

@media (min-width:96rem){.container{max-width:96rem}}
Enter fullscreen mode Exit fullscreen mode

.container has zero uses in 69,066 lines of application code. A media query ships for a screen size we never designed for, carrying a rule for a class we never use.

Every responsive prefix in the source

sm:        367 uses in 72 files
lg:        135 uses in 25 files
md:         50 uses in 23 files
xl:          5 uses in  3 files
2xl:         0 uses in  0 files
max-sm:      4 uses in  1 file
max-lg:      1 use  in  1 file
min-[420px]: 2 uses in  2 files
min-[360px]: 1 use  in  1 file
Enter fullscreen mode Exit fullscreen mode

Five of those 5 xl: uses: two xl:table-cell and one xl:block plus xl:ml-0 in the results table behind the login, and one xl:grid-cols-5 in the marketing footer. That last one is the only xl: utility that reaches a public page, and it is there once per page, 76 times in total:

<nav aria-label="Footer" className="grid grid-cols-2 gap-x-8 gap-y-8 sm:grid-cols-3 xl:grid-cols-5">
Enter fullscreen mode Exit fullscreen mode

Counting prefixes in the delivered HTML of all 76 pages:

Prefix Uses Pages carrying it Distinct utilities
hover: 5,143 76 10
sm: 1,795 76 48
lg: 802 76 25
md: 347 76 9
motion-reduce: 339 66 2
group-hover: 319 70 1
min-[360px]: 76 76 1
xl: 76 76 1
2xl: 0 0 0

The nine distinct md: utilities across the whole public site are md:block, md:flex, md:gap-8, md:grid-cols-2, md:grid-cols-3, md:hidden, md:order-none, md:table and md:text-sm. That is the complete vocabulary of our 768px breakpoint.

Which widths actually change a page

Class counts are not behaviour. The test that matters is: render the same page at one pixel either side of each boundary and count the elements whose layout-relevant computed styles differ. I drove Chrome through the DevTools protocol, setting the viewport with Emulation.setDeviceMetricsOverride before each load, and compared display, flex-direction, text-align, order, position, visibility, font-size and the number of grid columns for every element in the body.

page                                    elements  359/360  419/420  639/640  767/768  1023/1024  1279/1280  1535/1536
/pricing                                     978        0        0        3       12          5          1          0
/glossary                                    721        0        0        2        8          3          1          0
/guides/how-to-find-youtube-influencers      856        0        0        7        8          3          1          0
/for/agencies                                739        0        0        3        8          3          1          0
Enter fullscreen mode Exit fullscreen mode

Including padding and gap changes adds about four more elements at 640 per page. Nothing else moves.

So on a typical public page of this site, out of 700 to 1,000 elements:

  • 640px restyles two to seven elements. One of them is always the footer nav going from two columns to three.
  • 768px restyles eight to twelve, almost all of them display: a mobile block becoming a table cell, a hidden element appearing.
  • 1024px restyles three to five.
  • 1280px restyles exactly one element on every page, and it is the footer nav again, going from three columns to five. Measured in the browser: 232px 232px 232px becomes 126.398px 126.398px 126.398px 126.398px 126.406px.
  • 1536px restyles nothing. The media query fires (matchMedia("(min-width:96rem)").matches flips to true at exactly 1536), and because the only rule inside it targets an unused class, the page height is identical: 5,208px either side on the home page, 7,068px on the glossary.

That last line is the measurement I wanted. A week ago I checked that our pages render identically at 1280px and at 4K and concluded the design simply stops caring above a certain width. Now I know the mechanism: it stops caring at 1,280px, where one footer gains two columns, and the breakpoint above that is a no-op shipped by the framework's default theme.

The two custom boundaries never fire on a public page at all. min-[420px]:grid-cols-4 is on a stats row behind the login, and min-[360px]:inline-flex is one header button:

<Button asChild className="hidden min-[360px]:inline-flex">
Enter fullscreen mode Exit fullscreen mode

That button is hidden below 360px because it was the one thing that would not fit when I checked the site at 320px. A one-pixel audit found it; a one-rule media query fixed it.

What I take from this

The honest summary is that this site has two breakpoints, not five. 640px handles phone-to-tablet, 768px handles the few places where a table replaces a stack, 1024px handles the sidebar layouts, and the top two exist because they came with the toolkit.

Three changes, in order of how much they are worth:

  1. Delete nothing. The 27 bytes of the 2xl block and the 174 of xl are not a performance problem, and container may be used later. Saying "we audited this and it is fine" is a legitimate outcome, and the audit took an hour.
  2. The nine md: utilities are a vocabulary small enough to write down, so write it down. A responsive scale nobody can recite is a scale nobody can use consistently, and ours fits in one line of a design note.
  3. The footer is the only element on the public site that responds to the top two breakpoints. If I ever want to prove that a layout change is design rather than habit, that is the element to start from.

You can reproduce the whole thing from outside: load the pricing page, the glossary or any guide at 1279px and 1280px, and watch the footer columns. Everything above the footer will be byte-for-byte the same.

Top comments (0)