Swizec Teller - a geek with a hatswizec.com

Senior Mindset Book

Get promoted, earn a bigger salary, work for top companies

Senior Engineer Mindset cover
Learn more

    Chrome's console.log is the slowest

    JavaScript is great. You can slice & dice huge datasets on the fly, and play with them, and explore them, and turn them into pictures. All live in the browser.

    Not “big data” huge, more like “Holy shit 5 years ago this would crash my browser” huge. Like, you’re playing with a dataset on 177,830 salaries1 in the US software industry, and your computer doesn’t even notice until you do something stupid.

    Something like debug your code, reload a bunch of times, and maybe console.log the whole dataset to make sure it parsed.

    That’s, what…? Like, 10 seconds of high CPU load for one console.log? Something like that. The more you do it, the longer it takes.

    Here’s what reading that output looks like:

    As long as that CPU load is high, you can’t do much. After a few tries, even your reload button stops working and you have to forcefully crash the browser tab to get back to work.

    It’s so annoying because everything else is so damn fast! Want to .map your dataset? No biggie, 10ms max. Want to .filter? 10ms. Want to filter and map and flush React updates to DOM and do all the things? You won’t even notice it does anything.

    But debugging your code… eesh. Can’t console.log very well, React dev tools are glacial, and god forbid you try to inspect element if there are thousands of DOM nodes on the page.

    Not to mention the initial page setup. Loading and parsing the dataset (CSV) from cache takes about 3 seconds, running the initial setState takes about a second. That’s up to 5 seconds between every full page reload and seeing output.

    5 seconds might not sound like a lot, but it adds up. I don’t know about you, but I run my code at least once every minute. That’s 5 minutes of waiting every hour, 40 minutes in a work day, and 3 working hours in a week.


    “Don’t console.log your whole dataset then.”

    Thank you, Captain Obvious. console.log(data[0]) is your best friend in these situations.

    And yet, you can do a lot by changing your browser.

    Safari makes logs useful right away. It even shows property types. That was a nice surprise.

    Firefox makes the output easy to work with, too. But it struggles if you quickly traverse into a deep part of the output.

    As far as presentation quality goes: Safari is shiniest, Firefox is practicalest, and Chrome is spartaniest.

    Oh, and Firefox wins the overall “How long do I have to wait before I can test my code?” challenge as well2. You can shave a few milliseconds off the initial setState({data: foo}) call.


    Fascinating. I’m a total nerd ? ?

    1. Playing with the dataset is in progress; pretty pictures in a week or two. ↩︎

    1. Tests were run manually in each browser. The graph shows average time for each operation. ↩︎

    Published on September 28th, 2016 in Chrome, Firefox, Google Chrome, safari, Technical

    Did you enjoy this article?

    Continue reading about Chrome's console.log is the slowest

    Semantically similar articles hand-picked by GPT-4

    Senior Mindset Book

    Get promoted, earn a bigger salary, work for top companies

    Learn more

    Have a burning question that you think I can answer? Hit me up on twitter and I'll do my best.

    Who am I and who do I help? I'm Swizec Teller and I turn coders into engineers with "Raw and honest from the heart!" writing. No bullshit. Real insights into the career and skills of a modern software engineer.

    Want to become a true senior engineer? Take ownership, have autonomy, and be a force multiplier on your team. The Senior Engineer Mindset ebook can help 👉 swizec.com/senior-mindset. These are the shifts in mindset that unlocked my career.

    Curious about Serverless and the modern backend? Check out Serverless Handbook, for frontend engineers 👉 ServerlessHandbook.dev

    Want to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz React components your whole team can understand with React for Data Visualization

    Want to get my best emails on JavaScript, React, Serverless, Fullstack Web, or Indie Hacking? Check out swizec.com/collections

    Did someone amazing share this letter with you? Wonderful! You can sign up for my weekly letters for software engineers on their path to greatness, here: swizec.com/blog

    Want to brush up on your modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com

    By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️

    Created by Swizec with ❤️