Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

raspberryrippl3/Chrome-Devtools-Code-Coverage-Parser

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

Chrome Devtools Code Coverage Parser

Simple PHP script to extract used CSS from a Google Chrome Devtools coverage JSON export. The export feature was added in Chrome 73

Note: This script was created to work when you 'record' in DevTools coverage across pages. Behaviour of the coverage tool seems to change over time (see: https://bugs.chromium.org/p/chromium/issues/detail?id=811983) and no longer records coverage across pages and has been deemed a feature request. You can still use it on one page but there's no real point in that.

It appears the last version to support coverage across pages was 60.0.3091.0. For Ubuntu you can get a version (59) from https://www.slimjet.com/chrome/google-chrome-old-version.php

Update the following variables:

$target_css = relative URL of the specific stylesheet you want to parse from the coverage export

$json_string = path to your Google Chrome coverage JSON export file

$output_filename = the name of the resultant CSS file you want

Example on a test site

Purging a CSS file of unused styles, saving approx 300 KB

Before:

before

After:

after

The process isn't perfect, especially on styles that are changed dynamically (like nav menus for example) by scripts. But it's a lot better than trying to use post-css or similar.

Best advice is to run it through the parser and see where the obvious problems are with removed styles, extract those specific CSS rules into their own stylesheet (e.g. remove it from being picked up by the Chrome coverage report), then run through the process again on the stylesheet.

About

Simple PHP script to extract used CSS from a Google Chrome coverage export

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.