Determining which assets are not being used in Rails?

流过昼夜 提交于 2019-12-05 18:38:34

I found some links but haven't tried them yet. I will report back when I get a chance to try them out:

discover-unused-partials

A script to help you finding out unused partials. Good for big projects or projects under heavy refactoring. Covers Haml and ERB.

deadweight

Deadweight 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.

Searching production.log

There is a handy blog post called Removing deadweight, describing how to grep through the production log and a script to find and delete assets that have not been seen.

The grep command they use is:

grep -Eo ‘GET /(.*(.gif|.jpg|.jpeg|.png|.css|.js))[ \?]’ access.log > ~/assets.txt
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!