O'Reilly logo

Mastering jQuery by Alex Libby

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working out unused JavaScript

So far, we've seen how we can easily minify code without any effort – but what if minifying isn't enough, and we need to remove redundant code?

Well, we can manually eyeball the code – nothing wrong with that. It's a perfectly acceptable way of working out what we can remove. The key thing though is that it is a manual process, which requires a lot of time and effort – not to mention the frequent attempts to find code that we can remove without breaking something else!

A smarter move is to set Node to work out for us what is being used, and what could be safely dropped. The web performance expert Gaël Métais has created unused JS to help with this. It works with Node, and is available at https://www.npmjs.com/package/unusedjs ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required