A Lifehack for removing unused JS/CSS.. or just unminify (2024)

To reduce page size plus your user's data usage and improve loading speed (depending on your audience) it is best to minify JS and CSS files. Fortunately, many developers or just plugins are already doing this by default. However..

Table of Contents

  • Unminify JavaScript and CSS in your browser
    • Chrome DevTools Coverage panel for unused JS and CSS
    • Detailed steps for viewing unused JS and CSS
  • Unused CSS/JS benefits of Chrome DevTools Coverage
    • Lighthouse: Remove unused JavaScript
    • Why removing is JS important

.. minifying these files makes it more difficult to see what exactly is happening in such files. Finding unused JS for example is a lot more difficult in a file that has been minified.

Unminify JavaScript and CSS in your browser

In order to more easily see what is going on in a file and come up with proper recommendations, I always unminify files. Before, I did this in way too many steps, I'll spare you the details of this and just jump to a better solution.

Because, when using Chrome's solution for determining unused JavaScript and CSS, you basically get this feature out of the box!

Chrome DevTools Coverage panel for unused JS and CSS

The Chromium DevTools offers this solution. You can find it via the following steps:

  1. Open Chrome DevTools
    • Control + Shift + I
    • or Command + Alt + I on Mac
  2. Open the Command Menu
    • Control + Shif t +P
    • or Command + Shift + P on Mac
  3. Type + click the following: "Show Coverage"
  4. Click the reload button to reload the page and to see which code is loaded
  5. Then double click on the JS or CSS file that you want to unminify.
    • The file gets opened in a new pane, unminified, even if the original file is minified by the developer, build proces or CDN.

Detailed steps for viewing unused JS and CSS

I am always using the shortkeys, but you can also use the steps shown in the image below.

Once you got DevTools opened up, for example using right click within the window and picking "Inspect element", go to Customize and control DevTools [1.] in the top right.

A Lifehack for removing unused JS/CSS.. or just unminify (1)

Within the context menu, pick "More Tools" and then "Coverage" [2.]. Then click the reload button within the Coverage panel, identified by "Start instrumenting coverage and reload page" when using a screenreader. A table with CSS and JS files will be filled, with the following columns:

  • URL, showing the urls of the resources;
  • Type, indicating if the file is a JS or CSS file;
  • Total bytes of the file;
  • Unused bytes;
  • Usage Visualization, to also get a grasp of the relative usage.

You can then double click on any file listed [3.], to see the unminified version and start determining what could be removed.
A faster alternative to unminify JS and CSS code can be found at devtoolstips.org.

Unused CSS/JS benefits of Chrome DevTools Coverage

Using this method has a number of advantages. First, it makes it considerably easier to read the files as a developer. Additionally, the Coverage function indicates which parts of the code in the files are not used. The image above clearly shows that the Google Developers environment itself parses quite a bit of unused JS.

Lighthouse: Remove unused JavaScript

You might recognize the following recommendation which could be seen when running a test in Lighthouse or PageSpeed Insights:

A Lifehack for removing unused JS/CSS.. or just unminify (2)

The screenshot says: "Remove unused javascript to reduce bytes consumed by network activity". To get this message, I made a screenshot of Google PageSpeed Insights analyzing the developers.google.com environment because, well.. I like the irony ;)

Finally, when using the Coverage tab in order to determine and fix unused bytes, the tool clearly indicates which file contains the most unused code via the "Usage Visualization" column. This makes it easy to see the (not always quick) wins of a page when it comes to removing unused code.

Why removing is JS important

JS will block the main thread of the browser, impacting performance. What that looks like, can be seen in the pagespeed impact visualization as part of the blogpost about fixing chatbot performance.

You were able to determine the bottlenecks, but are wondering how to properly address this issue for once and for all? You're not the first, just get in touch or let me perform a pagespeed and JavaScipt performance audit on your site or shop.

A Lifehack for removing unused JS/CSS.. or just unminify (2024)
Top Articles
Investing Basics: 14 Simple Strategies for Building Long-Term Wealth | NewRetirement
Building a Long-Term Investment Strategy
Napa Autocare Locator
Www.politicser.com Pepperboy News
Comforting Nectar Bee Swarm
Sportsman Warehouse Cda
Beds From Rent-A-Center
Crime Scene Photos West Memphis Three
Dark Souls 2 Soft Cap
Seth Juszkiewicz Obituary
Aita Autism
Craigslist Cars Nwi
6th gen chevy camaro forumCamaro ZL1 Z28 SS LT Camaro forums, news, blog, reviews, wallpapers, pricing – Camaro5.com
The Shoppes At Zion Directory
Restaurants Near Paramount Theater Cedar Rapids
Swedestats
Caledonia - a simple love song to Scotland
EASYfelt Plafondeiland
Winco Employee Handbook 2022
Ac-15 Gungeon
Chime Ssi Payment 2023
Turbo Tenant Renter Login
Cb2 South Coast Plaza
At 25 Years, Understanding The Longevity Of Craigslist
Panolian Batesville Ms Obituaries 2022
No Limit Telegram Channel
208000 Yen To Usd
Table To Formula Calculator
Anesthesia Simstat Answers
Weather Underground Durham
Craigslist Sf Garage Sales
Grand Teton Pellet Stove Control Board
Ixlggusd
Ixl Lausd Northwest
Amici Pizza Los Alamitos
Louisville Volleyball Team Leaks
Reborn Rich Ep 12 Eng Sub
Dr Adj Redist Cadv Prin Amex Charge
The Thing About ‘Dateline’
Silive Obituary
התחבר/י או הירשם/הירשמי כדי לראות.
Exam With A Social Studies Section Crossword
Rocket Lab hiring Integration & Test Engineer I/II in Long Beach, CA | LinkedIn
Aznchikz
Used Auto Parts in Houston 77013 | LKQ Pick Your Part
15:30 Est
Rocket Bot Royale Unblocked Games 66
Coleman Funeral Home Olive Branch Ms Obituaries
Nfsd Web Portal
Buildapc Deals
라이키 유출
Lorcin 380 10 Round Clip
Latest Posts
Article information

Author: Mr. See Jast

Last Updated:

Views: 6312

Rating: 4.4 / 5 (75 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Mr. See Jast

Birthday: 1999-07-30

Address: 8409 Megan Mountain, New Mathew, MT 44997-8193

Phone: +5023589614038

Job: Chief Executive

Hobby: Leather crafting, Flag Football, Candle making, Flying, Poi, Gunsmithing, Swimming

Introduction: My name is Mr. See Jast, I am a open, jolly, gorgeous, courageous, inexpensive, friendly, homely person who loves writing and wants to share my knowledge and understanding with you.