{"id":13596013,"url":"https://github.com/aanand/deadweight","last_synced_at":"2025-05-15T07:06:19.251Z","repository":{"id":618085,"uuid":"257003","full_name":"aanand/deadweight","owner":"aanand","description":"NOT MAINTAINED","archived":false,"fork":false,"pushed_at":"2016-04-27T14:52:46.000Z","size":149,"stargazers_count":1187,"open_issues_count":14,"forks_count":50,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-04-14T12:58:55.679Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mlbright/forecast","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aanand.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-07-21T19:04:25.000Z","updated_at":"2025-03-24T12:54:46.000Z","dependencies_parsed_at":"2022-07-05T04:00:21.738Z","dependency_job_id":null,"html_url":"https://github.com/aanand/deadweight","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aanand%2Fdeadweight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aanand%2Fdeadweight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aanand%2Fdeadweight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aanand%2Fdeadweight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aanand","download_url":"https://codeload.github.com/aanand/deadweight/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254291832,"owners_count":22046418,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T16:02:04.418Z","updated_at":"2025-05-15T07:06:14.240Z","avatar_url":"https://github.com/aanand.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"Deadweight\n==========\n\nWARNING\n-------\n\nThis project is no longer maintained. I recommend that you use a different tool. I don't have a specific one to suggest, having never used any, but [PurifyCSS](https://github.com/purifycss/purifycss) and [UnCSS](https://github.com/giakki/uncss) both seem to be actively worked on.\n\nOverview\n--------\n\nDeadweight is a CSS coverage tool. Given a set of stylesheets and a set of URLs, it determines which selectors are actually used and reports which can be \"safely\" deleted.\n\nScreencast!\n-----------\n\nRyan Bates has worked his magic once again. [Head over here for an excellent introduction to Deadweight](http://railscasts.com/episodes/180-finding-unused-css).\n\nHow to Install It\n-----------------\n\n    $ gem install deadweight\n\nHow to Use It\n-------------\n\nThere are multiple ways to use Deadweight. It's designed to be completely agnostic of whatever framework (or indeed language) your website is built on, but optimised for Ruby and Rails.\n\n### Run it From the Command Line ###\n\n    $ deadweight -s styles.css -s ie.css index.html about.html\n    $ deadweight -s http://www.tigerbloodwins.com/index.css http://www.tigerbloodwins.com/\n    $ deadweight --root http://kottke.org/ -s '/templates/2009/css.php?p=mac' / /everfresh /about\n\n### Integrate it With Your Integration Tests ###\n\nDeadweight can hijack your Rails integration tests (both the spartan Test::Unit type and the refreshing Cucumber variety), capturing every page that is returned by your app during testing and saving you the trouble of manually specifying a ton of URLs and login processses.\n\nFirst, put this in your `Gemfile`:\n\n    group :test do\n      gem 'colored'\n      gem 'deadweight', :require =\u003e 'deadweight/hijack/rails'\n    end\n\nThen, run your integration tests with the environment variable `DEADWEIGHT` set to `true`:\n\n    rake test DEADWEIGHT=true\n    rake cucumber DEADWEIGHT=true\n\nLet me know how it goes. It's not terribly customisable at the moment (you can't specify what exact stylesheets to look at, or what selectors to ignore). I'm looking for your feedback on how you'd like to be able to do that.\n\n### Rake Task ###\n\n    # lib/tasks/deadweight.rake\n  \n    require 'deadweight'\n  \n    Deadweight::RakeTask.new do |dw|\n      dw.stylesheets = [\"/stylesheets/style.css\"]\n      dw.pages = [\"/\", \"/page/1\", \"/about\"]\n    end\n\nRunning `rake deadweight` will output all unused rules, one per line. Note that it looks at `http://localhost:3000` by default, so you'll need to have `script/server` (or whatever your server command looks like) running.\n\n### Call it Directly from Ruby ###\n\n    require 'deadweight'\n  \n    dw = Deadweight.new\n    dw.stylesheets = [\"/stylesheets/style.css\"]\n    dw.pages = [\"/\", \"/page/1\", \"/about\"]\n    puts dw.run\n\n### Pipe In CSS Rules from STDIN ###\n\n    $ cat styles.css | deadweight index.html\n\n### Use it as an HTTP Proxy ###\n\n    $ deadweight -l deadweight.log -s styles.css -w http://github.com/ -P\n\nSetting the Root URL\n--------------------\n\nBy default, Deadweight uses `http://localhost:3000` as the base URL for all paths. To change it, set `root`:\n\n    dw.root = \"http://staging.example.com\"      # staging server\n    dw.root = \"http://example.com/staging-area\" # urls can have paths in\n    dw.root = \"/path/to/some/html\"              # local paths work too\n\nWhat About Stuff Added by Javascript?\n-------------------------------------\n\nDeadweight is completely ignorant of classes, IDs or tags added by your Javascript layer, but you can filter them out by setting `ignore_selectors`:\n\n    dw.ignore_selectors = /hover|lightbox|superimposed_kittens/\n\nThe command-line tool also has basic support for [Lyndon](http://github.com/defunkt/lyndon) with the `-L` flag, which simply pipes all HTML through the `lyndon` executable to execute any embedded or linked JS.\n\nYou Can Use Mechanize for Complex Stuff\n---------------------------------------\n\nSet `mechanize` to `true` and add a Proc to `pages` (rather than a String), and Deadweight will execute it using [Mechanize](http://mechanize.rubyforge.org/mechanize):\n\n    dw.mechanize = true\n\n    # go through the login form to get to a protected URL\n    dw.pages \u003c\u003c proc {\n      fetch('/login')\n      form = agent.page.forms.first\n      form.username = 'username'\n      form.password = 'password'\n      agent.submit(form)\n      fetch('/secret-page')\n    }\n\n    # use HTTP basic auth\n    dw.pages \u003c\u003c proc {\n      agent.auth('username', 'password')\n      fetch('/other-secret-page')\n    }\n\nThe `agent` method returns the Mechanize instance. The `fetch` method is a wrapper around `agent.get` that will abort in the event of an HTTP error status.\n\nIf You Install `colored`, It'll Look Nicer\n-------------------------------------------------\n\n    gem install colored\n\nCopyright\n---------\n\nCopyright (c) 2009 Aanand Prasad. See LICENSE for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faanand%2Fdeadweight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faanand%2Fdeadweight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faanand%2Fdeadweight/lists"}