<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by JP de Vries on Medium]]></title>
        <description><![CDATA[Stories by JP de Vries on Medium]]></description>
        <link>https://medium.com/@jpdevries?source=rss-b5cd7146107------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Bt0UrJexHcP3X0bfI1sLXw.png</url>
            <title>Stories by JP de Vries on Medium</title>
            <link>https://medium.com/@jpdevries?source=rss-b5cd7146107------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 23:45:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jpdevries/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Please stop calling React a framework]]></title>
            <link>https://medium.com/@jpdevries/please-stop-calling-react-a-framework-c600028d01d7?source=rss-b5cd7146107------2</link>
            <guid isPermaLink="false">https://medium.com/p/c600028d01d7</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[JP de Vries]]></dc:creator>
            <pubDate>Wed, 24 May 2017 20:23:52 GMT</pubDate>
            <atom:updated>2017-05-24T20:24:11.260Z</atom:updated>
            <content:encoded><![CDATA[<p>React is not a framework.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c600028d01d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Count the “Clicks”]]></title>
            <link>https://medium.com/@jpdevries/count-the-clicks-60719720f88b?source=rss-b5cd7146107------2</link>
            <guid isPermaLink="false">https://medium.com/p/60719720f88b</guid>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[ux]]></category>
            <dc:creator><![CDATA[JP de Vries]]></dc:creator>
            <pubDate>Fri, 12 May 2017 00:58:14 GMT</pubDate>
            <atom:updated>2017-05-12T10:07:22.077Z</atom:updated>
            <content:encoded><![CDATA[<p>I optimized 998 clicks for a given user story down to just 4 and this is how you can too.</p><p><em>Not all users click. Some tap the screen or keys on a keyboard. Others may use dictation to interact with your interface. In this post we’ll refer to any single user interaction as a “click”.</em></p><p>How many clicks does it take to accomplish tasks within your interface? Each click is an exhaustive investment made by your users. If they begin to feel they aren’t getting a return on their investment they will bounce leaving you with a unsuccessful conversion. Reducing the clicks in your experience is one way to improve the usability and conversion rate of your interface.</p><p>One of the goals of the <a href="http://github.com/jpdevries/eureka">Eureka Media Browser redesign</a> was to reduce the number of clicks required for users to achieve tasks. Let’s examine the number of clicks required to delete files in the original browser and compare that to the redesign. Originally, there were no bulk select features so deleting media items cost N * 2clicks, where N is the number of items to be deleted. Deleting one item cost two clicks; deleting 100 media items costs 200 clicks. As the number of items grew our clicks grew linearly with it.</p><p>Once the bulk select feature was added I was able to reduce the number of clicks by removing multiplication from the equation. Users can individually select multiple items, and then click a delete button to delete them all. Our algorithm is now N + 1, which, as seen in the chart below, is a fantastic improvement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nKWNFmg3JBhgyh4z0NjYFQ.png" /><figcaption>The number of clicks required to delete multiple items is significantly reduced using bulk selection</figcaption></figure><p>But we aren’t done yet. Imagine a scenario where we have a large folder of media items, let’s call it 500 items, and we want to delete <em>all but two of them</em>. With our original design this would cost 996 clicks (498 * 2). Why are you crying? With bulk selection this would cost 499 clicks (498 + 1). Either way, that is a lot of clicks. This is where the invert selection feature comes in. A user can now select the 2 items they don&#39;t want to delete, invert the selection, and delete all 498 media items with just four clicks. So for this scenario we’ve optimized 998 clicks all the way down to 4!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*swdxXfp7P6lyqRUQu-tnTQ.gif" /><figcaption>Deleting 486 items in just 3 clicks using inverted bulk selection</figcaption></figure><p>So what does this “inverse selection” algorithm look like?<br>(T - (T - N)) + 1 + 1 where T is the total number of media items and N is the number of items to omit. With invert selection we save them the total number of items minus the items they’d like to omit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HMpvZAAByPlmAUfvwwMVeg.png" /><figcaption>Inverting selected items allows actions to be performed on many items efficiently</figcaption></figure><h3>Conclusion</h3><p>Once we’ve written an algorithm that represents clicks necessary for a user to perform we can work on reducing user exhaustion. Look for multiplication and repitition within your algorithm and explore design patterns to allow for a more efficient user experience. Consider utilizing modern APIs such as localStorage to automatically jump users back to where they were. Treat each click as an investement made by the user and do what you can do give them an adequate return. Rest assured that if your interface allows them to take shortcuts using just a few clicks odds are they will be more likely to return. Less is more, especially when it comes to clicks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60719720f88b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[rems and ems, and why you probably need them]]></title>
            <link>https://medium.com/@jpdevries/rems-and-ems-and-why-you-probably-need-them-ff99a0002cdd?source=rss-b5cd7146107------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff99a0002cdd</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[digital-typography]]></category>
            <category><![CDATA[a11y]]></category>
            <dc:creator><![CDATA[JP de Vries]]></dc:creator>
            <pubDate>Sun, 07 May 2017 12:30:10 GMT</pubDate>
            <atom:updated>2017-05-09T07:39:16.895Z</atom:updated>
            <content:encoded><![CDATA[<p>The holy “px vs em” war wages on. But it never should have started. Not because one side is absolutely correct, but because these design decisions should not be reduced to binary. It’s not all or nothing or one or the other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tRDf7-Xl0xEWvVhLxIA5_w.jpeg" /><figcaption>An unfocused lense captures the bokeh effect and reminds us not all users are perfectly sighted</figcaption></figure><p>This is a response to David Gilbertson’s <a href="https://hackernoon.com/rems-and-ems-and-why-you-probably-dont-need-them-664b9ce1e09f">rems and ems, and why you probably don’t need them</a> post and addresses each section in order.</p><h3>It’s definitely better for accessibility</h3><p>David writes:</p><blockquote><em>My point: you don’t need in depth knowledge and fancy tools for working out if rems and ems are ‘better for accessibility’ — just imagine that you are someone with bad eyesight</em></blockquote><p>This may be well intended but is ridiculous advice nonetheless. You can’t just “imagine” disability. Abled developers making naive assumptions about what a disabled person would want is <a href="https://uxdesign.cc/the-inaccessible-web-how-we-got-into-this-mess-7cd3460b8e32">how we got into this mess</a>. The fact remains <a href="http://engageinteractive.co.uk/blog/em-vs-rem-vs-px">users expect to be able to increase font sizes using the user agent</a>, not just browser zoom. Need proof? Survey visual impaired users asking they if they’d appreciate a website responding to their font–size preferences, not just “browser zoom”.</p><p>As an abled person, don’t put yourself in the mindset of a disabled person. You can’t. Instead engage with disabled communities, ask them questions, hire them for usability testing and consulting. Listen to them; don’t just imagine you are disabled and proceed to speak for them.</p><p>David writes:</p><blockquote><em>I don’t know about you, but if I had trouble reading small text, I’d bump up the default font size for the OS and forget about it.</em></blockquote><p>He’s right. We don’t know about our users, which is why we should avoid these assumptions like they are tabular layout. Web pages that set font size in pixels do not respond to font size preferences such as those found in Google Chrome, the most popular web browser. But we can assume that they can use operating system settings instead right? Not exactly. Keep in mind that for a variety of reasons users might not even have access to operating system level settings. I know I didn’t when I was studying as a visually impaired design student in computer labs. Or at the local library.</p><p>As web developers it is not our job to assume what users will or can do. We should respond to and support their accessibility preferences in any and all areas for an inclusive and world wide experience.</p><p>David writes:</p><blockquote><em>Although we have no evidence as to whether or not people rely on changing their browser text size</em></blockquote><p>The use of assistive technology doesn’t show up in Analytics Dashboard but that doesn’t mean there is no evidence to be found. Expand your perspective beyond developers who, drunk on practices that favor themselves over end users, pat themsleves on the back for malpractice. Go to an accessibility conference, or a meet up, and talk to visually impaired people. Gather evidence by engaging directly with the disabled community. Don’t expect their sensitive accessibility preferences and health information to be tracked online.</p><blockquote><em>The above facts, to me, make it crystal clear that browser text size adjustment is of no use in the real world. And so I will not take this setting into account in my decision making process.</em></blockquote><p>This is an assumption that seems to have been made without consulting the visually imparied community or acknowledging the existence of <a href="https://dbaron.org/css/user/">User Stylesheets</a> so I will not take this assumption into account in my decision making process and neither should you.</p><p>There is a misconception that because browser zoom will scale font size now we don’t need to worry about font size preferences anymore. It is important to understand that browser zoom and font size preferences are two fundamentally different things. Similar to pinch zoom on a mobile device, browser zoom scales the <em>entire interface</em>. Whereas the design is scaled with browser zoom and either introduces horizontal scrolling or adapts by responding to breakpoints and adjusting layout, font size preferences only increase the size of text and relative units — not the entire interface. Users with motor disabilities may be more inclined to zoom entire interfaces, increasing the hit areas of clickable elements, while visually imparied users may enjoy the ability to only increase font size and related relative units.</p><h3>Breakpoints scale when you use rems/ems</h3><p>In this section David points out that modern browsers will scale pixels along with browser zoom. Browsers did not originally to do this. In response to the rampant misuse of declarative pixel units browsers made a breaking change to how they interpret CSS units. Make no mistake, if all web developers used CSS in accordance with the CSS specification and accessibility best practices, browsers would not have made this change.</p><p>Now that browsers forcefully scale pixel units, designers have actually lost the capability to declare that “no for reals, this text should <em>always</em> be 10px even when the browser is zoomed or font size preferences are adjusted”. In other words, we can’t declaratively set type anymore. Why would a designer want to do this? Type isn’t just used for legibility; it is also used as illustration and texture. Thanks to rampant misuse of CSS units, designers no longer have the capability to size HTML text declaratively as illustration or texture as they did before.</p><h3>Use ems for ‘dynamic’ spacing around text</h3><p>David acknowledges the fluid nature of relative units:</p><blockquote><em>This is almost a good idea, I see where the proponents are coming from. “Why change font-size and padding, when you can use ems for the padding, then only change the font size?” they say in their outside voice.</em></blockquote><p>Prior to citing his own personal preference:</p><blockquote><em>I just prefer…</em></blockquote><p>There it is folks — the underlying misprioritization that <a href="https://uxdesign.cc/the-inaccessible-web-how-we-got-into-this-mess-7cd3460b8e32">got us into this mess</a>. Somewhere along the line we started putting ourselves at the center of our designs, but <strong>it’s not about us; </strong>it’s about our end users. A responsible web architect does not values their own personal preferences over inclusive design pattern and accessibility best practices. Imagine a builder explaining to a home buyer, “you know, the building code states I should set studs 16 inch on center so the house doesn’t cave in on your family during an earth quake, but I just prefer 24 inch on center. Much easier to work with.”</p><p>Allow your visitors to use familiar and standardized practices to control the legibility of their experience. And don’t justify poor practice with common usage. Flash was popular once.</p><h3>Make modules that you can resize simply by changing the root element font-size</h3><blockquote><em>I can’t recall the last time I wanted a component that grew in all dimensions, paddings and font-sizes, by the same factor, by changing just one value.</em></blockquote><p>Ok. But again, <strong>this isn’t about you</strong> the developer. Ask your audience if they can remember the last time they wanted to use the user agent to be able to control the scaling of components on the page. And remember that if there is a lack of disabled representation within your audience that may be because the design isn’t inclusive to begin with.</p><p>Setting type and layout declaratively because you don’t want to do math or whatever may benefit you as a developer. Does it benefit your users in any way? No. Does it lessen their ability to control the legibility of their experience? Absolutely. The experiences you design should revolve around your users — not you. They’ll still be using the experiences you create long after pack up your tools and leave the job site.</p><p>Imagine an architect saying “You know, I can’t recall that last time I needed to use brail in the elevator. Let’s leave that out”. There are probably architects that don’t enjoy designing around accessibility requirements but I’m sure we can agree it would not only be ridiculous, but illegal, for them to favor themselves over the needs of an inclusive society. And the web should be no different.</p><h3>You can scale all the text on your page with one property</h3><p>David demotes the notion that anyone would want to scale components flexibly:</p><blockquote><em>It assumes that you want to increase/decrease all text on your site at the same time for a given breakpoint. Headings, menu items, body text, all at once, all by the same factor. Now that’s courage.</em></blockquote><p>That is literally exactly what a visually impaired user would expect when setting something like the following CSS in a user sheet for your web site.</p><pre>#thing-i-need-to-see-better {<br>  font-size: 200%;<br>}</pre><p>Please. Stop making your design decisions about you and start making them about what your world wide audience expects.</p><h3>In conclusion</h3><p>David concludes:</p><p><em>I think it all boils down to this: there are times when you should use rems and ems — they’re in the spec for a reason.</em></p><p>Amen brother. He continues:</p><p><em>So don’t go looking for a reason to use ems and rems. It is enough to what they do. Use pixels, and if a scenario pops up where ems or rems are the better tool for the job, go for it.</em></p><p>It’s not about you looking for reasons to use, or to not use, a tool based on you as a developer. End users don’t care what CSS units any of us prefer or why — base your decision making on end user experience and working towards a more world wide and inclusive web for everyone.</p><p>David makes some valid and noteworthy points on why relative units are less critical today than they were years ago. It is certainly true that ten years ago you wouldn’t of been able to get a job writing CSS if you set type in pixels, but today you’re Senior Developers will probably be not only be setting type in pixels but doing so directly in JavaScript. Which inclusive design patterns you decide to use is ultimately up to you, but please don’t buy into the myth that all you need to do is put on your “disability thinking cap” and imagine yourself as a disabled person to make design decissions on their behalf. We’ll never architect <a href="https://www.youtube.com/watch?v=KW6ivwDcOY4">a web for everyone</a> that way.</p><p>ps: Don’t take it from me. <a href="http://fantasai.inkedblade.net/style/talks/best-practices/#relativity">Take it from CSS spec authors</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*whXFxgBtYEWWbbBfU1dQmA.png" /><figcaption>Liquid layouts and relativity, <a href="http://j4p.us/1c3b0e0Q3N1k/Screen%20Shot%202017-05-07%20at%2011.26.34%20AM.png">when to use which CSS units</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff99a0002cdd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Give your Forms some Form]]></title>
            <link>https://medium.com/front-end-weekly/give-your-forms-some-form-2ec73cb36981?source=rss-b5cd7146107------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ec73cb36981</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[html5]]></category>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[JP de Vries]]></dc:creator>
            <pubDate>Wed, 12 Apr 2017 12:33:22 GMT</pubDate>
            <atom:updated>2017-04-14T19:41:55.243Z</atom:updated>
            <content:encoded><![CDATA[<p>The year is 2017 and for better or worse JavaScript is everywhere. Tools like React allow us to virtualize our documents, making turning web pages into web applications more approachable than ever. But sometimes what we can do with these tools conflicts with what we should do with them.</p><p>As Web Developers we should remind ourselves what the “web” fragment of our job title stands for. The “web” stands for the “world wide web”. Until we make contact with aliens in a distant galaxy, and also have to start considering their accessibility needs, world wide is as inclusive as it gets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*Fe-C8-E0_55qSs7rc3bUlg.jpeg" /><figcaption>Tim Berners-Lee reminds the world that the web is for everyone — 2012 Summer Olympic Games.</figcaption></figure><p>HTML Forms are a fundamental feature of the web and give us a reliable way to accept user input. To get that far though, we need to make sure all our users can input and submit data in the first place. Ideally, our initial HTML layer includes forms that use the action attribute so that even if JavaScript is disabled, or breaks, our forms remain performant.</p><p>Progressive Enhancement attracts best practices. Since we have to use HTML forms in our initial HTML layer for it to work at all — <em>they are already there</em>. Easy peazy. Conversely, the JavaScript–first patterns often found in Single Page Applications (SPAs) may attract poor practices. These tools are shiny and new but they also make it too easy for us to overlook the twenty years of web standards that preface them. For example consider this React component:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2974c4784fbfc6e0c7ad1591e8d809e3/href">https://medium.com/media/2974c4784fbfc6e0c7ad1591e8d809e3/href</a></iframe><p>Makes sense right? We can type a search term in the input, click the search button, and our props.onSubmit method is called. There are a few issues here:</p><ul><li>not all users click</li><li>our submit “button” is only accessible to sighted mouse users</li><li>Our form is not a form, it is a div</li><li>our input is not labeled</li><li>incorrect usage of placeholder</li><li>we are not leveraging the Form Validation API</li></ul><p>Here’s another pattern I’ve been noticing lately:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5111f6acdea3edfc42ef27e2588622d7/href">https://medium.com/media/5111f6acdea3edfc42ef27e2588622d7/href</a></iframe><p>Short and sweet right? Well, for sighted keyboard users yes it is. Issues with this pattern include:</p><ul><li>There is no submit button</li><li>Our input is not labeled</li><li>Our form is not compatible with user agents that may submit forms in any way other than dispatching a keyDown press of the Enter key</li><li>Our form is not a form, it is a div</li><li>incorrect usage of placeholder</li><li>we are not leveraging the Form Validation API</li></ul><p>So let’s give our form some form:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36750c5d7f4559331c21e485bfb8462e/href">https://medium.com/media/36750c5d7f4559331c21e485bfb8462e/href</a></iframe><p>We’ve changed our div.search to form[role=&quot;search&quot;]. Our form will now be added to the Accessibility Tree as a standard form and bring all the magic of web standards, such as the HTML5 Form Validation API, along with it in addition to hinting to assistive technology that this is a search component. Notice the required attribute we added. This indicates to the browser that if the input is left blank the Form submit event should not fire, and instead alert the user they must input a valid search term. We&#39;ve described our input with a standard label and are correctly using the placeholder attribute. Placeholder is meant to offer an example of a valid entry to an input; not to describe an input. So for example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4bdb56ed675c4dd56ed9e154c8f0c709/href">https://medium.com/media/4bdb56ed675c4dd56ed9e154c8f0c709/href</a></iframe><p>We are also listening to the native form submit event, rather than making assumptions on how that form may be submitted. This technique is immeasurably more accessible as it <strong>lets the user agent be in charge of how a form is submitted</strong>. We’ve added a standard submit button. Our submit button is clever without us having to add any code to make it so. Whether it is clicked, or the enter key is pressed with the button focused, it will submit our form for us.</p><h3>Visually Hiding Form Labels</h3><p>We should be proud of our semantic form, &lt;label&gt; and all. But our Art Director might not be so pleased. Perhaps the visual label conflicts with their design. That is OK. We can visually hide the label without removing it from the accessibility tree. Everybody wins. Add this <a href="http://a11yproject.com/posts/how-to-hide-content/">CSS snippet to your stylesheet which will give you a </a><a href="http://a11yproject.com/posts/how-to-hide-content/">.visually-hidden class</a>. Now add that class to your &lt;label&gt;.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d46d265a820cc41a9c1c6839bb2912c7/href">https://medium.com/media/d46d265a820cc41a9c1c6839bb2912c7/href</a></iframe><p>Alternatively to the .visually-hidden pattern you can label the input using the aria-label attribute:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/52b7afb41f6d1b34e59ac6c41f023502/href">https://medium.com/media/52b7afb41f6d1b34e59ac6c41f023502/href</a></iframe><h3>Meaningful Placeholder Attributes</h3><p>Earlier we covered that the placeholder attribute is meant to offer a suggestion, an example of a valid entry, not describe an input:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c679ca0648cd3ef0573911fd4b83f236/href">https://medium.com/media/c679ca0648cd3ef0573911fd4b83f236/href</a></iframe><p>Kittens. It should <strong><em>always be kittens</em></strong>.</p><p>Whenever we use a tool, we should ask ourselves “What unique capabilities does this tool have? Am I using these capabilities to their full potential?” When I asked myself this about React, I realized it is particularly excellent at updating the DOM for us. This means that, rather than using a static placeholder value like “kittens” we could use a dynamic value. We could ensure that the placeholder attribute of our Filter component is always suggesting an example of a valid entry that would <em>actually yield results</em>. Take the <a href="https://github.com/jpdevries/eureka#eureka-">Eureka Media Browser</a> for example, its filter component will display a placeholder according to the following algorithm:</p><ul><li>every X seconds and/or when updating the current directory, pick a random media item from the current directory</li><li>pick a random property of the media item, such as filename or file size</li><li>set placeholder to this random property of a random media item</li></ul><p>So the input component actually updates its placeholder attribute on a setInterval. This educates the user by presenting them with a variety of valid entries they could use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*b-9opaDI7T9LyBZq25WmhQ.gif" /><figcaption><a href="https://github.com/jpdevries/eureka#eureka-">Eureka Media Browser</a> cycling through valid entries that would yield results for filtering the current directory</figcaption></figure><h3>Typeahead Hints with &lt;datalist&gt;</h3><p>HTML 5.2 adds the &lt;datalist&gt; element which is used by modern browsers to create pure HTML typeahead components. An&lt;input&gt; decorated with &lt;datalist&gt; is kind of like <a href="http://jpdevries.github.io/datalist/">if </a><a href="http://jpdevries.github.io/datalist/">&lt;input&gt; and </a><a href="http://jpdevries.github.io/datalist/">&lt;select&gt; got together and had a baby</a>. Users can type whatever they want, but they can also choose from a list of options.</p><p>Here is an example of using &lt;datalist&gt; to decorate an input with React. Notice we leverage the virtual nature of React to bind our &lt;datalist&gt; options to our state. <a href="https://glitch.com/edit/#!/assorted-price/public/scripts/main.js:19">Visit the interactive example on Glitch</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9abe9c0f77d704b3f4f9a41680dcf3e2/href">https://medium.com/media/9abe9c0f77d704b3f4f9a41680dcf3e2/href</a></iframe><h3>Conclusion</h3><p>With great power, the VirtualDOM makes poor practices and best practices alike more feasible. And with great power comes the responsibilities of architecting a <em>web for everyone</em>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ec73cb36981" width="1" height="1" alt=""><hr><p><a href="https://medium.com/front-end-weekly/give-your-forms-some-form-2ec73cb36981">Give your Forms some Form</a> was originally published in <a href="https://medium.com/front-end-weekly">Frontend Weekly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[There is no Speed in Web Performance]]></title>
            <link>https://medium.com/markuptips/there-is-no-speed-in-web-performance-1457f6ee79a3?source=rss-b5cd7146107------2</link>
            <guid isPermaLink="false">https://medium.com/p/1457f6ee79a3</guid>
            <category><![CDATA[html5]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[JP de Vries]]></dc:creator>
            <pubDate>Thu, 06 Oct 2016 13:07:50 GMT</pubDate>
            <atom:updated>2016-10-07T06:28:44.452Z</atom:updated>
            <content:encoded><![CDATA[<p>Within the Web Development industry we say that if a page loads quickly it has good performance. But we’re wrong.</p><p>There are several definitions to the word performance but the only definition that is even remotely close to referring to speed is:</p><blockquote>performance: the capabilities of a machine, product, or vehicle</blockquote><p>That definition has the following synonyms: working, operation, running, behavior, capabilities, capacity, power, potential. Don’t worry you aren’t missing anything. Speed is not a synonym for performance. But if web performance is not about speed what is it about?</p><p>Web performance is about reliability. If a page, site, or application successfully caries out a given task then it performed that task and is therefore performant. It is a web performance. It may be slower than molasses in the winter time at performing that task but it performed it nevertheless.</p><blockquote>performance: the action or process of performing a task or function</blockquote><p>It is odd to me that inaccessible “single–page” JavaScript–first web apps which don’t work at all in older browsers are considered performant. These agressively enhanced experiences may be asynchronous and snappy in modern browsers but they cake their pants when they come across a syntax error or an older browser…they may be highly optimized but they are not performant. At all. Sorry.</p><blockquote>Web Performance has far more to do with accessibility than it does speed.</blockquote><p>So how do you architect the web for performance? Progressive Enhancement! By starting your experience using HTML to semantically markup your content you will have a document that is backwards and forwards compatible. Before you move on to styling your document, and long before you move on to enhancing it with scripts, focus on achieving as much as possible with HTML first. If you follow this process you should be able to remove the scripts and even the stylesheet and still be left with a performant document.</p><p>Now that we got that cleared up, I can’t wait to visit your next performance!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1457f6ee79a3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/markuptips/there-is-no-speed-in-web-performance-1457f6ee79a3">There is no Speed in Web Performance</a> was originally published in <a href="https://medium.com/markuptips">MarkupTips</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CSS is !important]]></title>
            <link>https://medium.com/markuptips/css-is-important-960a9921e454?source=rss-b5cd7146107------2</link>
            <guid isPermaLink="false">https://medium.com/p/960a9921e454</guid>
            <category><![CDATA[a11y]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[JP de Vries]]></dc:creator>
            <pubDate>Sun, 04 Sep 2016 13:30:52 GMT</pubDate>
            <atom:updated>2016-10-13T22:02:49.956Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GxhBNLNhGt9IqKyDBnjv8g.jpeg" /><figcaption>A cascade of windows with a select few uniquely ajar</figcaption></figure><p>Cascading Style Sheets are designed to, well, cascade. !important declarations overrides the cascading nature of CSS and are often considered to be a hack. You should avoid using them for the most part. But like most things proposed to the CSS spec, !important has several practical applications. But what are they?</p><p>First we need to travel back in time. Long before media queries and responsive design. The !important keyword was first introduced in CSS1 as a way to increase the specificity of CSS declarations. But it did something rather strange.</p><blockquote>When !important was first introduced in CSS1, an author rule with an !important declaration held more weight than a user rule with an !important declaration; to improve accessibility, this was reversed in CSS2<br> — <a href="https://www.smashingmagazine.com/2010/11/the-important-css-declaration-how-and-when-to-use-it/">The Important CSS Declaration How and When to use it</a></blockquote><p>Author stylesheets are included by web developers in a web page to style the page. User styles are defined by the user often in their browser preferences. It makes sense that a user style should always override author styles, but that wasn’t always the case.</p><blockquote><em>However, for balance, an “!important” declaration (the delimiter token “!” and keyword “important” follow the declaration) takes precedence over a normal declaration. Both author and user style sheets may contain “!important” declarations, and user “!important” rules override author “!important” rules. This CSS feature improves accessibility of documents by giving users with special requirements (large fonts, color combinations, etc.) control over presentation.<br> — </em><a href="http://www.w3.org/TR/CSS2/cascade.html#important-rules"><em>W3C Recommendations — !important rules</em></a></blockquote><p>So there you have it. Straight from the CSS2 Specification, <strong>the !important feature improves accessibility of documents</strong>. It isn’t just a hack.</p><h3>Accessibility</h3><p>The CSS authors made an important decision to make !important declarations in user style sheets the most specific of them all. A user should have the final say in the styles they are presented with. This isn’t the only advantage to the changes made in the CSS2 spec however. Inadvertently, this ruling also allows web developers to use !important declarations freely without concern of overriding !important user styles.</p><p>We shouldn’t expect all users in need of stylistic considerations to be savvy enough to author their own user styles. Using JavaScript localStorage and a simple form we can create preference widgets that allow users to specify their preferences. Our author stylesheets then respond to user preferences accordingly. Using JavaScript to promote accessibility along with responsive design, sounds like a plan. Let’s look at a few examples.</p><h3>Visually Hidden</h3><p>Sometimes you want to hide an element visually but not semantically. For example, maybe a label doesn’t need to be visually but does need to be accessible to screen readers. The A11Y Project has a well tested technique for this using a .visually-hidden class. Notice the use of !important.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6d57b6d053563e0236562369e102e69/href">https://medium.com/media/d6d57b6d053563e0236562369e102e69/href</a></iframe><h3>Font Size</h3><p>Whether visually impaired or just sitting far away from your screen, we can all appreciate larger font size from time to time. We’ll create a medium font size that is 20% larger than normal and a large font size that is another 20% larger than medium.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04519e8bb150726d42ecc070152d0c90/href">https://medium.com/media/04519e8bb150726d42ecc070152d0c90/href</a></iframe><p><em>Note: Depending on your cascade and styles you may not need to use important declarations for setting font-size on the body element. Only use !important in your declarations if necessary or if stylesheets outside of your control may be included in the page.</em></p><p>Using classes on our body element is fine and well, but once we start using JavaScript to asynchronously reflect user preferences they can be a bit cumbersome. For example, we don’t want to have to remove the medium class each time we add the large class and vice–versa. So let’s use a data attribute instead.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97105e0386038718a19d84dfd7958c94/href">https://medium.com/media/97105e0386038718a19d84dfd7958c94/href</a></iframe><p>Now with one simple setAttribute we can update our page to reflect the user’s preferences.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0191910593274d3a40b36202a3209a3/href">https://medium.com/media/d0191910593274d3a40b36202a3209a3/href</a></iframe><p>Very nice, but we’re not there yet. A splash of HTML and a sprinkle of JavaScript and we’ll have a user friendly component that allows them to choose their !important font-size.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6e93e90b89b67d565f46b4daf9291be/href">https://medium.com/media/c6e93e90b89b67d565f46b4daf9291be/href</a></iframe><p>And now for the JavaScript.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e0873d034b5e089fe88f29676ccf2efa/href">https://medium.com/media/e0873d034b5e089fe88f29676ccf2efa/href</a></iframe><p>Here is our Font Size Preference Widget as a CodePen. Try it out.</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fcodepen.io%2Fjpdevries%2Fpen%2FQKwLxz&amp;src=https%3A%2F%2Fcodepen.io%2Fjpdevries%2Fembed%2Fpreview%2FQKwLxz%3Fheight%3D600%26amp%3Bslug-hash%3DQKwLxz%26amp%3Bdefault-tabs%3Dhtml%2Cresult%26amp%3Bhost%3Dhttp%253A%252F%252Fcodepen.io%26amp%3Bembed-version%3D2&amp;type=text%2Fhtml&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca17c8a91cb895c35780f78cd580d66e/href">https://medium.com/media/ca17c8a91cb895c35780f78cd580d66e/href</a></iframe><p>Okay, I know what you are thinking. This is a CSS post about !important declarations. Now that we’ve architected a preference widget, let’s get back to it.</p><h3>High Contrast Mode</h3><p>Increasing font size is a great way to improve legibility but we need to consider contrast as well. Even large black text on a white background may be illegible to users with particular eye conditions. By supporting a high contrast mode that forces backgrounds to black and font color to white we can accommodate users with particular eye conditions and night owls alike. Everybody wins.</p><p>To enable our high contrast mode we’ll add a .high-contrast class to our HTML element that forces all elements on the page to black background white white border and font colors.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/821917d03122532949f63a691ae0021b/href">https://medium.com/media/821917d03122532949f63a691ae0021b/href</a></iframe><p>Sure we could use more specific selectors to override each area of our stylesheet that sets background, color, and border-color properties. But that would be difficult to maintain and increase our CSS weight. With just three !important declarations we can specify how all elements should be styled when in high contrast mode without overriding any !important declarations in user sheets.</p><p>Of course our JavaScript to toggle the high contrast mode is as follows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ede9e1f5a54f52878531da33746ae17d/href">https://medium.com/media/ede9e1f5a54f52878531da33746ae17d/href</a></iframe><p>You can use the patterns outlined above to create a similar widget that allows users to set their contrast preferences. <a href="https://markup.tips/settings.html#contrast">Visit markup.tips for an example</a>. In supported browsers you can even allow the user to choose automatic switching between high contrast and normal contrast based on the luminosity of their current environment. At the time of this writing, Firefox is the only browser to support the HTML5 Luminosity API needed for this feature.</p><p>If you are working with high contrast modes don’t forget to <a href="https://msdn.microsoft.com/en-us/library/windows/apps/hh465764.aspx">checkout the -ms-high-contrast feature</a> and stay tuned as this feature <a href="https://wiki.csswg.org/spec/mediaqueries4#high-contrast-mode">hopefully works its way into CSS Media Queries Level 4</a>.</p><h3>Reducing Motion</h3><p>CSS Transitions and Keyframe Animations are a great way to add character to an experience. While many users find animations and transitions entertaining they can be intrusive and even detrimental to others. Whether this is because they experience motion sickness or just aren’t in the mood, it is important we give users a way to opt out of animations and transitions.</p><p>Create a preference widget that allows users to opt out of unnecessary motion. When they choose to reduce motion, prevent CSS Transitions and Animations will the following styles.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/247982100140e3b204601e9f5b58591b/href">https://medium.com/media/247982100140e3b204601e9f5b58591b/href</a></iframe><h3>Font Family</h3><p>Typography is a critical design element. Graphic Designers put great effort into choosing the web fonts they deliver. But design isn’t just about how something looks. Perhaps more importantly design is about how something functions in society. Even the most aesthetic typefaces may not be legible to all users. Particular fonts have been designed to accommodate these users. For example,<a href="http://opendyslexic.org/">OpenDyslexic is a font created to increase readability for users with dyslexia</a>. Unlike print, the web offers the ability to asynchronously change the fonts on a page. So let’s leverage the nature of our medium by allowing users to do so. Depending on the nature of your cascade, you may need to use !important declarations to ensure the font the user prefers is used for all the appropriate elements on the page.</p><p>Create a widget that allows users to set their font preferences and make OpenDyslexic an option. <a href="https://markup.tips/settings.html#typeface">Visit markup.tips for an example of allowing users to choose their font</a>. Not only does this technique allow for a more inclusive design but it also can be used to increase site performance by <a href="https://medium.com/@jpdevries/10k-tips-for-a-lighter-page-load-39e188298ac7#bb84">initially serving a web safe font and allowing users to opt into heavier web fonts</a>.</p><h3>Print Styles</h3><p>In 2010 Louis Lazaris wrote <a href="https://www.smashingmagazine.com/2010/11/the-important-css-declaration-how-and-when-to-use-it/">an excellent article published by Smashing Magazine titled “!important CSS Declarations: How and When to Use Them”</a>. In it he reminds us that while it may not always be necessary, !important declarations can be used within print media queries to override specific styles without having to repeat selector specificity.</p><p>To be considerate of the environment and your user’s paper supply we’ll use some !important declarations to force printed pages to black text on a white background. We’ll also remove advertisements and navigational elements such as the site nav and search components.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/67e633f386209837ae9fe162ee9ed4fd/href">https://medium.com/media/67e633f386209837ae9fe162ee9ed4fd/href</a></iframe><p>Most users would probably prefer to choose between color or grayscale printing in their print dialog box but you can force grayscale printing with a CSS filter.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/059b7934c5c72ce020aa3d75c46e7f50/href">https://medium.com/media/059b7934c5c72ce020aa3d75c46e7f50/href</a></iframe><p>Perhaps you use the grayscale filter together with a preference widget that allow users to set their print preferences so they are reflected on their next visit.</p><h3>To Hack Inline Style</h3><p>Using the style HTML attribute will override CSS declarations regardless of selector specificity. For this reason inline style should be avoided. If you find yourself working on a project where inline styling is present and cannot be feasibly removed you can hack them away with !important declarations. An !important declaration in a stylesheet will override inline style. It might not be the most ideal fix, but it works. For example, an absurd amount of !important declarations were needed to <a href="https://github.com/modxcms/revolution/pull/12776">make the MODX 2.5 Manager Interface more mobile friendly</a>.</p><h3>Never</h3><p><a href="https://www.smashingmagazine.com/2010/11/the-important-css-declaration-how-and-when-to-use-it/#never">Louis put it best in his post</a>.</p><blockquote>!important declarations should not be used unless they are absolutely necessary after all other avenues have been exhausted. If you use !important out of laziness, to avoid proper debugging, or to rush a project to completion, then you’re abusing it, and you (or those that inherit your projects) will suffer the consequences.<br> — <a href="https://www.smashingmagazine.com/2010/11/the-important-css-declaration-how-and-when-to-use-it/#never">!important CSS Declarations: How and When to Use Them</a></blockquote><p>So remember, only use !important declarations if they are absolutely necessary or are improving accessibility. It might feel hacky but if a few !important declarations allow you to feasibly support a high contrast mode, it’s worth it.</p><p>In this post we’ve covered some practical uses of !important declarations but what is most important is you architect your styles to meet the best needs of your users and your team. So what do you think? What is most important to you and yours?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=960a9921e454" width="1" height="1" alt=""><hr><p><a href="https://medium.com/markuptips/css-is-important-960a9921e454">CSS is !important</a> was originally published in <a href="https://medium.com/markuptips">MarkupTips</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10k Tips for a Lighter Page Load]]></title>
            <link>https://medium.com/markuptips/10k-tips-for-a-lighter-page-load-39e188298ac7?source=rss-b5cd7146107------2</link>
            <guid isPermaLink="false">https://medium.com/p/39e188298ac7</guid>
            <category><![CDATA[progressive-enhancement]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-performance]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[JP de Vries]]></dc:creator>
            <pubDate>Wed, 31 Aug 2016 15:11:02 GMT</pubDate>
            <atom:updated>2016-09-01T12:42:57.085Z</atom:updated>
            <content:encoded><![CDATA[<p>Oh. You were expecting 10,000 tips weren’t you? You won’t find that many tips today. At least not here. But you will find some tips for keeping the initial weight of your progressively enhanced web experience under 10,240 bytes (10kB).</p><p>Perhaps you’ve heard of <a href="https://a-k-apart.com/">this year’s 10K Apart Competition</a>. Or maybe you are just looking for some tips on how to optimize and measure performance byte–by–byte. Either way, let’s get started.</p><h3>Start with HTML</h3><p>Starting with HTML–first is crucial to creating lightweight progressively enhanced experiences. It is also the center of an accessible experience. JavaScript is great, but <a href="https://gds.blog.gov.uk/2013/10/21/how-many-people-are-missing-out-on-javascript-enhancement/">not all users receive JavaScript</a>. Think of JavaScript like glass. It is incredibly useful but heavy and fragile. Challenge yourself to initially work within the limitations of synchronous design patterns of HTML for a lighter and more accessible experience. Constraints are a designer’s coach. You might not be fond of them, but they foster creativity and genius. Could that WYSIWYG graphics editor be enhanced from a standard HTML form? Could that fancy asynchronous markdown editor be enhanced from a good old fashion &lt;textarea&gt;? Spend some time working within the constraints of HTML and rest assured, you’ll be amazed with the solutions you discover.</p><h3>Zip it Up</h3><p>GZIP is pretty much magic. It drastically reduces the weight of assets like HTML, CSS, and JavaScript by sending them compressed to the client. For example, a 65kB HTML document can weigh as little as 5kB once GZIP’ed. If you have to choose between minifying your CSS and JavaScript or delivering them unminified and compressing choose the later. The <a href="https://css-tricks.com/the-difference-between-minification-and-gzipping/#article-header-id-2">difference in weight between a minified compressed file and an unminified compressed file</a> is fairly negligible. An unminifed compressed file will always weigh less than a minified uncompressed file. So zip it before you ship it.</p><h3>Be Lazy About It</h3><p>I’m going to quote Wikipedia. Because I’m lazy.</p><blockquote>Lazy loading is a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed. — <a href="https://en.wikipedia.org/wiki/Lazy_loading">Wikipedia</a></blockquote><p>Sometimes we consider loading an asset only once the entire HTML document has loaded “lazy–loading”. But unless that asset is needed immediately it isn’t lazy–loaded. Say you allow users to choose from a set of different themes. Perhaps one of which is a high–contrast mode. You could lazy load the stylesheet(s) for these themes by only loading them once their associated theme has been chosen.</p><h3>Lose the Font</h3><p>We love web fonts but they are heavy. Not serving a web font will keep your page weight down and your Google PageSpeed score up. So don’t use them (initially).</p><h3>Choose the Font</h3><p>Designers like web fonts. Users like web fonts. I like web fonts. You like web fonts. We all like web fonts. So let’s add web fonts optionally and progressively. As <a href="https://markup.tips/settings.html#typeface">demonstrated on markup.tips</a>, a simple web component can be used to give users the option to opt–in to the web font of their choice. Use localStorage to remember their choice so the next time they return, be it next week or next year, the site will be delivered in accordance with their preferences. This is also an accessibility consideration as it gives users the ability to opt into fonts like <a href="http://opendyslexic.org/">OpenDyslexic</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*mmy5Vrh8PRtgE4PR85BQjg.png" /><figcaption>Allow users to chose the typeface of their choice</figcaption></figure><h3>Silence Your Sass</h3><p>Sass is a CSS preprocessor. Over shadowed by the many other amazing things Sass allows you to do is the ability to use silent classes to group commonly used declarations together. Doing so will reduce the number of lines, and thus the weight, of your stylesheets. <a href="https://markup.tips/tips/thinkful-silence-your-css-footprint-with-sass-silent-classes.html#focus">Discover more on using silent classes with Sass in this post</a>.</p><h3>Go Vanilla</h3><p>With modern browsers gaining more and more market share <a href="https://markup.tips/tips/thinkful-silence-your-css-footprint-with-sass-silent-classes.html#focus">you might not need jQuery</a>. While the VanillaJS code you write may be less concise than jQuery syntax, freeing yourself of the weight of the jQuery library itself will keep the weight of your enhancement layer down.</p><h3>Don’t Load Scripts that Won’t Work</h3><p>So you’ve optimized your scripts. Sweet. But what features are required in those scripts? Are you loading scripts in browsers that won’t understand them? If you are using modern JavaScript you are probably making use of document.addEventListener and document.querySelector. In other words, you are supporting IE9 and newer. Before you load those scripts do a little feature detection.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ff159d9119ac7451c18f810197eddcc/href">https://medium.com/media/3ff159d9119ac7451c18f810197eddcc/href</a></iframe><p>Users may be stuck on an old browser for circumstances outside of their control. They could be using corporate machines they aren’t capable of updating or be in a country where modern operating systems and browsers are less accessible. Be considerate of these circumstances by only shipping usable bytes.</p><h3>Sloppy Scripts?</h3><p>Bare with me on this. You may be accustomed to writing well crafted JavaScript. Once you start measuring your scripts byte–for–byte you’ll notice that some of your well crafted coe is adding weight. In most cases this is well worth it. That class definition adds a little weight, but it also makes your codebase more extensible and legible. Using require() allows you to encapsulate and modularize your codebase but each required script is enclosed in some code that allows it to be included. Keep this in mind as you write your scripts and measure your weight incrementally. If you get too close to your bandwidth budget you may want to consider if these modern practices are worth the bytes they cost. Procedural code is sloppy but it also may weight less.</p><h3>Picture This</h3><p>The HTML5 &lt;picture&gt; tag offers art direction and bandwidth considerations. You can dictate which image should be displayed based on things like viewport size, pixel density, or even supported image formats. For example, <a href="https://developers.google.com/speed/webp/">WebP provides superior lossless and lossy compression</a>, but not all browsers support it. You can use the &lt;picture&gt; tag to deliver elements that load less bytes if superior formats are supported. Additionally you can only load high resolution images for screens capable of benefiting from high resolution images.</p><h3>Save Data</h3><p>Google has <a href="https://developers.google.com/web/updates/2016/02/save-data?hl=en">introduced a brilliant new header</a> that allows users, or their devices, to opt into saving data. The implementation is simple. If the client sets the save-data header to on you acknowledge that on the server–side and deliver a more efficient experience. Maybe you drop the web fonts and JavaScript enhancements. The save data header is an excellent complement to progressive enhancement because if you start with HTML first you can drop the JavaScript enhancement layer without losing base functionality. No harm no foul. If the user opts to save-data perhaps you optimize for leveraging the browser cache rather than optimizing initial page load times by <a href="https://medium.com/@jpdevries/unfolding-critical-css-91619401b4e#.vhl4a0kmk">more effectively leveraging the browser cache</a>. Responsive Design isn’t just about responding to viewport sizes. Responding to user preferences like the save-data header also makes for a more accessible and usable experience.</p><p>We’ve covered quite a few tips today. It’s probably time we let you get back to work on your next progressive and light weight addition to the web.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39e188298ac7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/markuptips/10k-tips-for-a-lighter-page-load-39e188298ac7">10k Tips for a Lighter Page Load</a> was originally published in <a href="https://medium.com/markuptips">MarkupTips</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sprinkle Some Hash on Your Headings]]></title>
            <link>https://medium.com/markuptips/sprinkle-some-hash-on-your-headings-ecd00bfd9811?source=rss-b5cd7146107------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecd00bfd9811</guid>
            <category><![CDATA[a11y]]></category>
            <category><![CDATA[web-accessibility]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[JP de Vries]]></dc:creator>
            <pubDate>Thu, 11 Aug 2016 12:56:02 GMT</pubDate>
            <atom:updated>2016-08-11T12:56:02.202Z</atom:updated>
            <content:encoded><![CDATA[<p>URLs (Uniform Resource Locators) are how we arrive at a given location on the web. Similar to how a building has a unique address, every web page has a unique URL. In addition to navigating to a specific webpage, URLs can take us to a <a href="#49e6"><em>specific part</em></a> of a webpage.</p><p>If you live in an apartment complex you have the same building address as your neighbor. Your apartment number along with the building address define your unique mailing address. Elements on a webpage have the same ability. Sheltered under the roof of the same DOM (Document Object Model), elements all live within the same “building”. Just like a unique apartment number, assigning a DOM element a unique id attribute allows that element to be directly linked to. Any visible DOM element with an id attribute can be accessed by its own unique fragment identifier.</p><blockquote>The fragment identifier introduced by a hash mark (#) is the optional last part of a URL for a document.<br> — <a href="https://en.wikipedia.org/wiki/Fragment_identifier">Fragment Identifier</a></blockquote><h3><a href="#49e6">Hash Mark</a></h3><p>At the end of a URL you can add a hash mark (#) followed by the id of a DOM element. This will cause the browser to scroll directly to that element. This is a very clever technique that can be used to share a specific section of a page. Let’s say you write a super awesome blog post. <a href="#49e6">Like this one</a>. And you want to share a particular section of that post. Before sending the URL to a friend all you need to do is add a URL fragment to the end of the URL with the id of the section you’d like to share.</p><p>But how does a user determine what the id of the section is? If they are technically savvy they can view the source of the web page and copy the id attribute of the section they want to share. Yuck. Most users won’t do that. This is why it is important to not only add id attributes to sections of your document but give users a way to easily access them as well.</p><p>Take this heading for example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc1622f6353f30b94f932f6687bee465/href">https://medium.com/media/dc1622f6353f30b94f932f6687bee465/href</a></iframe><p>Let’s say the heading is half way down our page. Without an id attribute we won’t be able to link users directly to the Yolo section. So let’s add an id attribute now by sprinkling some hash on our heading:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f099bc41544fd8405c85dbb26d60ba5/href">https://medium.com/media/1f099bc41544fd8405c85dbb26d60ba5/href</a></iframe><p>Much better. Now we can add #yolo to the end of our URL and users will be taken directly to that section.</p><p>We’ve added a capability to our page but we haven’t provided users an easy way to access that ability. We don’t want to keep the hash to ourselves, so let’s use an anchor tag to make our heading more sharable now:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54e8db399c699c4c29bd5bad70a152a9/href">https://medium.com/media/54e8db399c699c4c29bd5bad70a152a9/href</a></iframe><p>Our semantic heading now contains an anchor tag that links to its associated heading. When a user clicks this link their URL bar will be updated to contain the #yolo URL fragment and the document will also scroll immediately to that section. Like any other link, users can right click the anchor tag and copy the URL. When the user copies the URL the fragment will be included. This makes our semantic headings shareable.</p><p>Maybe you want to add this capability without making the heading look like a link. No problem. You can add a subtle class to your anchor tag and use CSS styles to make your heading look as it would without the link.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/894998a56030b11e664f10cea43ee0c8/href">https://medium.com/media/894998a56030b11e664f10cea43ee0c8/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cf7722bf3f20b9f80c455f040ea92fe/href">https://medium.com/media/7cf7722bf3f20b9f80c455f040ea92fe/href</a></iframe><p>Now your heading subtly provides the accessibility of a link while maintaining your heading styles. By adding an id attribute and an anchor tag you’ve made your headings easily sharable and more accessible. It’s the little things.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecd00bfd9811" width="1" height="1" alt=""><hr><p><a href="https://medium.com/markuptips/sprinkle-some-hash-on-your-headings-ecd00bfd9811">Sprinkle Some Hash on Your Headings</a> was originally published in <a href="https://medium.com/markuptips">MarkupTips</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Preparing React Components for Server–Side Rendering]]></title>
            <link>https://medium.com/front-end-weekly/preparing-react-components-for-server-side-rendering-18901d09784c?source=rss-b5cd7146107------2</link>
            <guid isPermaLink="false">https://medium.com/p/18901d09784c</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[JP de Vries]]></dc:creator>
            <pubDate>Mon, 08 Aug 2016 02:12:51 GMT</pubDate>
            <atom:updated>2016-08-08T13:05:40.559Z</atom:updated>
            <content:encoded><![CDATA[<p>You’ve been experimenting with React lately and you are aware that in accordance with accessibility, SEO, and performance best practices you should serve a semantic HTML document that React enhances — not creates. But how do you author an initial synchronous experience and an enhanced asynchronous experience isomorphically?</p><p>One of the most common arguments against progressive enhancement stems from the assumption that duplication is necessary to serve both synchronous and asynchronous experiences. Nobody wants to maintain wet code. DRY (Do–not–Repeat–Yourself) code is something we all should strive for. If we have to make an update in multiple areas of our codebase we increase the risk of introducing bugs. Plus we’re lazy.</p><p>But how do we author our initial HTML document and the components used to enhance it with the same source files? The answer may surprise you. If you’ve been using React on the client side, your components may be more ready to author your HTML documents than you think. In this post we’ll explore a few tips to prepare your React components for server–side usage.</p><blockquote><em>One of the great things about React is that it doesn’t require the DOM as a dependency<br> — </em><a href="https://facebook.github.io/react/docs/environments.html"><em>React Docs</em></a></blockquote><p><a href="https://facebook.github.io/react/docs/environments.html">React supports server–side environments</a>, but that doesn’t mean that any React component you create is compatible out of the gate. Because your Node server is naive. It has no idea what the DOM (Document Object Model) is.</p><p>For server–side usage you need to explicitly require React in any module that utilizes it. This isn’t necessary for client side usage where you can import React in your main.js entry point and go on using React freely in any modules you require. When using React on the server side we don’t have an entry point. Our components are standalone so we need to explicitly include React. At the top of your server–side components place this conditional include:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/db51065ad3a3cf01f9db4912e15603d1/href">https://medium.com/media/db51065ad3a3cf01f9db4912e15603d1/href</a></iframe><p>That was easy. What else? Chances are your components may be referencing the DOM in some way. Take this ToDoForm component for example. It has an updatePageTitle method that updates the title of the page based on how many uncompleted tasks the user is presented with.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ddd1fda5de5a1e37a2684684ce7d46c/href">https://medium.com/media/2ddd1fda5de5a1e37a2684684ce7d46c/href</a></iframe><p>Nothing to it right? Well, not so fast. When this component runs on the server–side it will confuse our Node server so bad it just won’t know what to do. Our request will eventually time out. We don’t like it when our requests time out, so let’s help our Node server not get so confused. The issue is our server–side environment does not understand what our document object is. We will detect if our component is running on the client side, or not, and proceed accordingly.</p><p>Create a helpers.js module. It will export a boolean serverSideRendering variable that will be true if we are running on the server.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6433fc4f1efee594296d3e6680f2483/href">https://medium.com/media/e6433fc4f1efee594296d3e6680f2483/href</a></iframe><p>If executed from the server the try statement will fail. And that’s ok. Our IIFE (Immediately Invoked Function Expression) will return true and our Node server will move right along. If executed on the client side, the try statement will not fail and the false expression !(document !== undefined) is returned.</p><p>We can now include our helpers.js module and use it to keep our Node server from getting confused. Let’s go back to our updatePageTitle method and immediately escape out of the function if we are running on the server–side.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e022fae909a780dc07873c11e0bbe597/href">https://medium.com/media/e022fae909a780dc07873c11e0bbe597/href</a></iframe><p>Your Node server thanks you. The DOM isn’t the only thing our Node server is oblivious to though.</p><blockquote><em>The Performance interface represents timing-related performance information for the given page.<br> — </em><a href="https://developer.mozilla.org/en-US/docs/Web/API/Performance"><em>MDN</em></a></blockquote><p>When our ToDoForm component mounts we want to instruct it to reach out for fresh data if there is a chance our content could be getting stale. So we’ve added a componentWillMount method that does just that:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/87def0cde6ede7bb0f3a2699e130763d/href">https://medium.com/media/87def0cde6ede7bb0f3a2699e130763d/href</a></iframe><p>Above we’re using the Performance interface to determine if the app has been running for more than 15 seconds. Nifty! One problem though. On the server side there is no Performance interface. Let’s save our Node server from confusion by slightly modifying our conditional.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9459cd6384ebf518791343a767d450b2/href">https://medium.com/media/9459cd6384ebf518791343a767d450b2/href</a></iframe><p>Excellent. Our Node server gets by with a little help from our helpers.js module. As you author React components don’t hesitate to use conditionals and try catch statements to shield your Node server from the unknown.</p><p>Now that we’ve prepared our React component to shield our Node server from client–side confusions, we’re ready to render our component on the server–side. From within our Node route, we’ll get the pending tasks, pass them to the same Redux store used on the client side, and render our ToDoForm on the server–side to be sent along with the initial HTML request.</p><p>We have a simple Twig template that includes a header, body tag, the React code we’ll pass in, and our scripts:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4dd0f48e97a21804fc895df7509c5132/href">https://medium.com/media/4dd0f48e97a21804fc895df7509c5132/href</a></iframe><p>And our Node server renders the server–side friendly ToDoForm component without a hitch:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/58f9e9cf20023f0676ad4b5aed6d551a/href">https://medium.com/media/58f9e9cf20023f0676ad4b5aed6d551a/href</a></iframe><p>Congratulations. You’ve leveled up your server–side rendering skills! That wasn’t so bad was it? We’ve been following along with some examples from the <a href="https://github.com/jpdevries/synctodo#sync-todo">Sync To Do source code</a>. You’ll find the working code and more examples there.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18901d09784c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/front-end-weekly/preparing-react-components-for-server-side-rendering-18901d09784c">Preparing React Components for Server–Side Rendering</a> was originally published in <a href="https://medium.com/front-end-weekly">Frontend Weekly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unfolding Critical CSS]]></title>
            <link>https://medium.com/markuptips/unfolding-critical-css-91619401b4e?source=rss-b5cd7146107------2</link>
            <guid isPermaLink="false">https://medium.com/p/91619401b4e</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[JP de Vries]]></dc:creator>
            <pubDate>Sat, 30 Apr 2016 14:01:46 GMT</pubDate>
            <atom:updated>2016-04-30T14:01:46.903Z</atom:updated>
            <content:encoded><![CDATA[<p>Inlining critical CSS is an optimization technique designed to make your site render blazingly fast. But does it?</p><p>A website is one or more web pages bound together by a domain, hyperlinks, commonly used assets, and the browser cache. Web pages are not websites. Websites are not web pages. Optimizations that lighten the payload of a web page may increase the payload of a website.</p><p>What is the difference between optimizing front end web pages and websites? How are files cached by the browser? When should you be designing for first visits and when should you be leveraging the browser cache? What is the payload of a website how is it affected by inlining performance techniques? Let us explore and discuss the differences between optimizing critical CSS for web pages and websites together.</p><p>Inlining critical CSS directly in your HTML improves the load time of your web page’s first visit but as your site is browsed the optimizations intended on making first impression snappier may slow subsequent visits down.</p><blockquote>Critical CSS makes your site render blazingly fast — especially on mobile.</blockquote><blockquote>CSS Stylesheets block rendering. Until a user’s browser has requested, received, downloaded and parsed your stylesheets, your page will remain blank. By reducing the amount of CSS the browser has to go through, we can get the page to render much, much faster.</blockquote><blockquote>Unfortunately it’s quite tedious to manually determine what css should be considered critical for a page. This tool removes that pain as it automates the process for you.</blockquote><blockquote>— <a href="https://criticalcss.com/about">About Critical CSS</a></blockquote><p>All true. Well, mostly true. Critical CSS focuses so much on optimizing web <em>pages</em> it looses focus of optimizing <em>websites</em>. If we can agree a website is a series of web pages, we can agree optimizing for a single page does not translate to optimizing for a site. Web pages are not websites, so decide before you start optimizing be sure and decide which one to target.</p><p>The first visit to a website is via a web page. In that first visit web browsers will cache external assets. Cached assets don’t have to be re–downloaded on subsequent visits. Leveraging the browser cache is a great way to optimize your website but does not optimize the load time of your first visit. In fact loading external assets slows your initial load down. Shipping inline styles that do not leverage the browser cache is a great way to optimize your first visit but by no measure optimizes the browsing experience of your website.</p><h3>Ask Yourself</h3><p>Are you building a single web page that users will visit once never to return to or are you building a multi–page website that most users click around on for a while? Will the content of your website be frequently updated? Do you expect users to return to the page within a short period of time? Regardless of what your users are doing now ask yourself what do you want them to do and design for that.</p><h3>Inlining CSS</h3><h4>The cost</h4><ul><li>Unable to leverage the browser cache</li><li>Heavier HTML payload</li><li>Heavier site payload</li></ul><h4>The reward</h4><ul><li>Faster initial page load times</li><li>No blocking HTTP request</li><li>No latency in retrieving a cached file</li></ul><p>If you are building a one page experience and your only performance concern is the first time the page loads then inlining CSS totally makes sense. Otherwise if you concerned with refreshing that page or visiting another page of the site within a short period of time, inlining CSS will send excessive bytes on each subsequent page request. If you keep to inlining only “critical CSS” such as the first 14kb or so of CSS to render the “above the fold” content this cost the amount of weight you are adding to your HTML isn’t much. Especially if GZIP is enabled, this won’t slow down your time to first byte on subsequent visits much.</p><p>Critical CSS avoids a blocking HTTP request by moving styles from external CSS styleheets to inline HTML. There is a toll all who inline styles must pay. Inlining CSS sidesteps the browser cache and cannot leverage the hyper–performance gained when assets are cached. Yes this will improve the perceived load time of the <em>first visit</em> but is that the only thing you are concerned about?</p><h3>Design for Success</h3><p>If you want a website that people click around on, design for a website that people click around on. If you want a website whose content will be frequently updated, design for a website whose content will be frequently updated. Design is about solving problems, but it isn’t just about solving the immediate problem. Challenge yourself to step back and consider the problems you will have <em>once your project goals are met</em>. You are a good Designer. Good Designers ultimately solve problems so plan for it!</p><h3>A Blazingly Friendly Mobile Site Experience</h3><blockquote><em>Critical CSS makes your site render blazingly fast — especially on mobile.</em> — <a href="https://criticalcss.com/about">About Critical CSS</a></blockquote><p>It might be more accurate to say that Critical CSS makes your pages render blazingly fast the first time a user visits them. If they refresh the page or visit another page of the site, Critical CSS increases your payload by not leveraging the browser cache. If they visit a URL that uses location hash to jump passed “the fold” to a specific part of the page then all the performance tuning you did for making above the fold content appear quicker were pointless.</p><p>Considering Critical CSS often increases the full browsed payload of your site, it is bold to claim to improve mobile <em>site</em> performance. Inlining critical styles improves initial <em>page</em> performance significantly. It does not improve returned visits to that page or visits to another page that makes use of those same inline styles. Ok, so there is a difference between optimizing for web pages an websites. But how do you know which to build for and what if you need to switch back and forth?</p><p>External stylesheets are blocking. Yikes! Afterwards the first request though they are pretty snappy. With <a href="https://devcenter.heroku.com/articles/increasing-application-performance-with-http-cache-headers">proper cache headers</a>, cached files are stored snuggly safe and sound in the browser cache where they can be re–requested without much latency. Once that upfront cost is paid you can re–deliver that same data on subsequent requests practically for free. If you do enough legwork upfront to optimize your site you may find yourself willing and able to ante–up for the cost of a blocking request to a stylesheet.</p><h3>Bandwidth as Accessibility</h3><p>Users on Capped Data Plans Pay by–the–Byte. If you were to evaluate the user experience of a movie you saw would you factor in the cost of the ticket? Users that enter your experience on capped data plans appreciate you being considerate on their data usage as they browse. Otherwise you may be unjustly charging them excessively to browse your experience. All the more reason to leverage the browser cache wherever we can. We may diminish our PageSpeed slightly score by doing so but our website is more user friendly. You can’t put a number on user exerpience, so don’t.</p><h3>The Quiz</h3><p>If you inline 20kB of the same critical CSS on 10 different pages how many kB of styles have you sent them?</p><p>How many HTTP Requests have you sent them for your inline styles?</p><p>If you load 20kB of the same critical CSS styles from a cacheable external stylesheet on 10 different pages how many kB of styles have you sent them?</p><p>How many HTTP Requests have you sent them for your external stylesheet?</p><h3>Leveraging the Browser Cache</h3><p>If you inline an average of ~20kB of critical CSS on each page and a user visits 10 pages that make use of those same styles you’ve served them 180kb of avoidable weight. That’s ~20kB of the same uncacheable non–blocking styles being downloaded 10 times (once for each page) vs ~20kB of blocking styles being downloaded once as part of a common stylesheet. The number of average page views per user should be taken into consideration when architecting your CSS delivery method.</p><p>Loading assets from common CDNs is a great way to leverage the browser cache. If you get lucky, your user already visited another website that used the same version of the same frameworks and when they arrive at your website for the first time those large frameworks don’t have to be requested at all! An of this is the HTML5 Boilerplate technique of loading jQuery from a common CDN. This means that all the websites that utilize HTML5 Boilerplate benefit from first attempting to load jQuery from a common CDN which may already be cached in the user’s browser.</p><p>What are the odds a user will have your framework already cached? Better than 0, and that is all that matters because there is no chance they will show up with a prepped cache if you are not loading frameworks from comomon CDNs.</p><h3>Don’t Forget the Hash</h3><p>In a proven effort to speed up first visits, Critical CSS forgets one important thing: the location hash.</p><p>The <a href="http://www.w3schools.com/jsref/prop_loc_hash.asp">location hash property</a> allows <a href="http://blog.hubspot.com/marketing/jump-link-same-page#hs_cos_wrapper_name">any part of an HTML page to be directly linked to</a>. It is unsafe to assume the top of your page will <em>always</em> be the first thing a user sees. Are you using the location hash to deep link to any parts of your website? May you utilize the ability to do so in the future? Are there ids on thinks like sections and headers so that users could link directly to sections of the website on their own?</p><h3>The Fold?</h3><p>Modules like grunt-criticalcss will determine what styles are and are not critical based off what is and isn’t above “the fold”. The concept is that if we look at what is displayed in the top 768px of our website on a 1024x768 viewport then we can consider any styles used in that section of the page critical, and everything else uncritical.</p><blockquote><em>If there ever was a fold responsive design killed it.</em></blockquote><p>The components visible within a desktop viewport may be completely different than the ones visible within a mobile viewport. But that’s not all. Stylesheets block for a reason.</p><h3>Stylesheets Block for a Reason</h3><p>By default browsers will cache most requests to stylesheets, images, and external JavaScript files. Unless configured otherwise, the HTML data itself will not be cached by the browser. This is because browsers know the HTML they consume can become outdated before it is even done being consumed. Allowing your HTML itself to be cached on the client side for a short period of time such as 5 minutes can be a clever way to make a site feel ultra–snappy as it is browsed.</p><p>Stylesheets are meant to load things the page needs right then right now. That’s why they block. If you chose to use loud frameworks like Bootstrap or Foundation your CSS weight got away from you quickly. Next thing you know you have these loud, heavy, blocking stylesheets loading on pages that use only a small percentage of the styles within them. Your root issue isn’t that external stylesheets were designed to block. Your root issue is your stylesheets were designed to block too.</p><p>Measure the percentage of your styles that are used on your pages. Consider measuring the percentage of your styles used on your whole website. If you are loading a significant percentage of styles that are never used then that’s square one. Start there. Critical CSS didn’t get you into this mess and it can’t get you out of it.</p><h4>TL;DR</h4><ul><li>HTML often isn’t cached</li><li>external stylesheets are often cached</li></ul><p>Global styles should be delivered once. Only once. With little exception, when they are are delivered they should be delivered in a cacheable manor.</p><p>Focus on delivering styles that are relevant to the specific page rather than a specific part of the page. If you are using id or name attributes in your markup people will find ways to share more specific parts of your pages. If you ever use the location hash to link to specific parts of your pages in your social media campaign you already inviting people to skip right passed “the fold” of your webpage.</p><h3>What Else?</h3><p>Here are some things you should consider prior to inlining styles:</p><ul><li>GZIP your stylesheets</li><li>Use far reaching expiry dates</li><li><a href="https://www.thinkful.com/projects/silence-your-css-footprint-with-sass-silent-classes-457/#focus">Use silent classes to Group selectors together</a></li><li>Keep your critical styles (layout) separate with preprocessors</li><li><a href="https://www.thinkful.com/projects/create-your-own-grid-system-with-some-neat-sass-442/#focus">Keep your CSS payload light with silent frameworks</a></li><li>Load common libraries from Common CDNs</li><li>Cache HTML (for a little bit)</li></ul><p>Once you have made the above considerations you should have a pretty snappy site. If your minified CSS weight is near 100kB, is there anything you can do to lighten your CSS payload? What percentage of loaded style are being used on your pages?</p><p>Still not snappy enough? At this point you may consider inlining CSS to improve perceived first loads.</p><h3>Don’t Listen to Me</h3><p>There is no absolute right answer here. As a Web Designer it is up to you to analyze your project and the weight of your assets against the browsing patterns of your users and make an educated guess on the best approach to take. Do your own performance testing. Test for the visitor patterns you have as well as the ones you want. If the visitor patterns you have are not the visitor patterns you want at that point you can decide to fail by never allowing yourself to succeed or you can design for the results you want. Usually clients want a website that people would return to or browse a little before leaving. Think twice before “optimizing” with a tool that is incapable of cashing in by leveraging the browser cache.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91619401b4e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/markuptips/unfolding-critical-css-91619401b4e">Unfolding Critical CSS</a> was originally published in <a href="https://medium.com/markuptips">MarkupTips</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>