My Mysterious Adventures in Browser Performance, Border Radiuses, and Live Video Streams
Tags: browserperformance, css, jank, webdev
Published: 2017-05-18 17:55:32

---
title: My Mysterious Adventures in Browser Performance, Border Radiuses, and Live Video Streams
published: true
description: Relying on my tools and a methodical debugging process to get to the bottom of a counter-intuitive user experience issue.
tags: browser-performance, css, jank, webdev
cover_image: https://thepracticaldev.s3.amazonaws.com/i/8k6et9xi5eq4uzh1dgt0.png
---

Yesterday, in a fit of inspiration, I decided to add a live feed of Google I/O to the [dev.to](/) home page.

I would love this platform to be the destination for discovery and discussion of what is going on, even more so than it currently is, and this was an experiment of sorts. Because the design of the site was friendly to this kind of addition, it was basically just a matter of adding a YouTube embed to the home page and making use of our existing feature toggling infrastructure to manage it.

<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">Thought it&#39;d be fun to show the <a href="https://twitter.com/hashtag/IO17?src=hash">#IO17</a> keynote on the <a href="https://t.co/E4yHRJkeOg">https://t.co/E4yHRJkeOg</a> home page. From idea to launch in 5 mins. Coding is fun ðŸ˜Š <a href="https://t.co/lsilQMCqGV">pic.twitter.com/lsilQMCqGV</a></p>&mdash; Ben Halpern (@bendhalpern) <a href="https://twitter.com/bendhalpern/status/864906227746209793">May 17, 2017</a></blockquote>

## But it's never that simple

The site became _janky_. Jank is when the browser's frame rate drops below the accepted threshold of about 60fps and things get glitchy weird. The browser's framerate, and other tools used to debug this sort of stuff can be found in Chrome's dev tools. Other browsers have similar setups.

![](https://thepracticaldev.s3.amazonaws.com/i/mgiy2hvql1gmj4ufkgzm.png)

The jank, as is often the case, was brought by the addition of weighty embeds like the YouTube player. There's not a whole lot we can do about that, besides complain.

<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">Google: Please make light, jank-free websites that load quickly.<br><br>Also Google: Use our super janky Youtube tags, ads, and tracking scripts. <a href="https://t.co/ZnFv3wcVKs">pic.twitter.com/ZnFv3wcVKs</a></p>&mdash; The Practical Dev (@ThePracticalDev) <a href="https://twitter.com/ThePracticalDev/status/848569465709244417">April 2, 2017</a></blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

But this page became _very_ janky. So it had to be more than just the YouTube embed. If I add a YouTube player to a plain old HTML page, the jank will be minimal. There had to be more.

So that's when I first opened my dev tools. The window's side panel opened up and I went to work.

_But the jank was gone_

That's right. When I opened up my dev tools, the problem went away. How could this be? The browser is in a different state when that panel is open, depending on what you have running within the tools. So I poked around and tried to find the answer. I could not.

_What the hell?_

I toggled some settings, changed some stuff around, and simply could not get to the bottom of it–**But then I figured it out!** It wasn't that the dev tools had fixed the problem, it was another variable: The slimmer window size brought on by the opening of the side panel had fixed the problem. When the window was smaller, there was no jank.

_But why?_

At first I thought something on the sidebar column of the page must be causing jankiness. When the sidebar goes away, things get better. But this was not the case. Then I thought it might have to do with some super inefficient CSS that only applies to certain media queries. That got me closer. The breaking point for jank was 850px. That is effectively when the page's layout changes between the slim look and the "desktop" look.

Looking at how the CSS varied between the different media queries, I could not eyeball what would possibly be causing so much jank. It was clear using the "Border Layers" dev tool, that there was a significant difference in how the browser was handling the rendering. Over 850px, the browser was working _way_ harder whenever I scrolled.

So I did what any professional software engineer does when faced with this kind of uncertainty.

<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">No book or teacher can beat good old fashion poking around. <a href="https://t.co/4JjAYA6p8G">pic.twitter.com/4JjAYA6p8G</a></p>&mdash; The Practical Dev (@ThePracticalDev) <a href="https://twitter.com/ThePracticalDev/status/720257210161311744">April 13, 2016</a></blockquote>

I toggled lines of CSS on and off until something happened. I'd run about ten cycles of toggle-then-check with no results. 

_And then it happened_

```css
border-radius: 3px;
```

That was the line. Commenting it out fixed all my problems. Rounded fucking corners. The main "articles list" area of the home page had a 3px border radius in the desktop view. Smaller than 850px, the list just takes up the whole screen, with no rounded corners.

This is not my first rodeo. I actually knew that border radius and box shadow and some other seemingly innocent CSS attributes can cause jank in certain scenarios, but I didn't think one element with rounded corners could cause these kinds of problems in practice.

### One ðŸ‘ Element ðŸ‘ With ðŸ‘ Rounded ðŸ‘ Corners

Try telling a designer they can't use rounded corners because it will cause the page to be basically unusable. Try having that conversation. I've had those kind of conversations. They are not easy to have because some of the browser's rules are so counterintuitive. Sometimes I can recalculate 1000 values per second and render complicated visuals, and sometimes I can't use fucking rounded corners.

<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">We can put a man on the moon but we can&#39;t effectively add rounded corners to a div ðŸ˜“ <a href="https://t.co/AJHq83QgYT">pic.twitter.com/AJHq83QgYT</a></p>&mdash; The Practical Dev (@ThePracticalDev) <a href="https://twitter.com/ThePracticalDev/status/865014187558305793">May 18, 2017</a></blockquote>

I found it ironic that this experience came about by trying to show a live stream of Google engineers and executives getting on stage and talking about the future of insane artificial intelligence, amazing new browser features, and all-in-all extolling the amazingness of the web, while I'm sitting here trying to render rounded-fucking-corners.

![](https://thepracticaldev.s3.amazonaws.com/i/m8ugapvo6pfkunpiyy2w.png)

But this post isn't about why we cannot have nice things, it's about learning and doing better. It is true, we can't have nice things, but there are definitely some takeaways.

## ðŸ”‘ Hire folks with T-shaped skills

It's scenarios like this that make me want to hire and work with people with T-shaped skillsets. That is, they have their specialty, but they have a breadth of understanding as well. In this case, if I were working with a designer, I would hope they have a basic understanding of how browsers deal with certain issues with rendering and how it's kind of counterintuitive and treated differently on different browsers. They don't need to know every detail, but designers who throw things over the wall are very unhelpful in this scenario.

<center><h3>T-Shaped Skills</h3></center>

![](http://www.irisclasson.com/wp-content/uploads/2013/07/T_shaped.jpg)

Likewise, engineers who don't respect the needs of designers are equally unhelpful. It's easy to veto a designer's decision instead of working with them to reach a compromise. In my case, I was both roles and I had to have this discussion with myself. It wasn't a very long discussion. I got rid of the rounded corners and I actually like it better this way.

## ðŸ”‘ Know your tools and use them

My other takeaway is that it pays to know your tools and use your tools early. I've faced situations in the past where I acted dumbfounded and allowed a problem to persist simply because I didn't really know how to deal with it. Having earned more experience with these tools, I was able to deal with this much sooner. And by dealing with the problem when it came up instead of thinking it was "good enough for now," it was easier to fix when it was all still in my head.

## ðŸ”‘ Coding is fun

My last takeaway is that coding is fun. I am glad I had the chance to take this chance and ship this feature on a whim. You can't always do that, but I am very glad my team trusts me to do things like this. I think we will learn a lot by trying out this idea of what the platform could be used for.

Happy coding â¤ï¸