Skip to content

anilg/asset_sweeper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Asset Sweeper

This gem is for cleaning up rails application by removing unused images, listing unused stylesheets and javascripts from application also with help of this you can list down missing images called from stylesheets which causes page loading slower.

Install

gem install asset_sweeper

It's also available in plugin form. You can install a plugin by following command.

ruby script/plugin install git://github.com/anilg/asset_sweeper.git

Usage

Run rake task

rake asset_sweeper:remove_unused_images -t

This rake task scans for all images (in “public/images” folder) (.jpg, .png, .gif) in application (rb, html, css, js files) and create a folder named unused in applications root directory and move images which are not used in application.

But if image name is constructed dynamically in code this script will miss such images.

rake asset_sweeper:list_unused_stylesheets -t

This rake task scans for all stylesheet names present in “public/stylesheets/*” folder in application (html files i.e. views) and list down as ununsed if it doesnt get any stylesheet being included in any of views in application.

But this rake task also lists all third party stylesheets as unused as it doesnt get their names in views. Also if stylesheets names are being constructed programatically even those stylesheets will be listed as ununsed ones. So before actually deleting stylesheets you have to verify manually whether that is being actually used or not.

rake asset_sweeper:list_unused_javascripts -t

This rake task scans for all javascripts names present in “public/javascripts/*” folder in application (html files i.e. views) and list down as ununsed if it doesnt get any javascript being included in any of views in application.

But this rake task also lists all third party javascripts as unused as it doesnt get their names in views. Also if javascripts names are being constructed programatically even those javascripts will be listed as ununsed ones. So before actually deleting javascripts you have to verify manually whether that is being actually used or not.

rake asset_sweeper:find_missing_images -t

This rake task will scan through all stylesheets present in application and verifies whether called images are present in application and list down all images path which are not present in application.

License

Copyright © 2011 Anil Galve

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages