0

I was looking at the unminified version of the 1.2.8 angular library (https://code.angularjs.org/1.2.8/angular.js). There are a number of directives that i will never use in my application, such as:

scriptDirective
ngBindDirective
ngBindHtmlDirective
ngNonBindableDirective
ngPluralizeDirective
ngTranscludeDirective

I removed all of the above, and corresponding code/functions. After recompiling my application, it performs as expected.

However, when i attempted to minify/uglify the file, im left with a file ~ 140kb in size. Yet, the original minified file size was ~98kb.

Ive used minify/uglify from Gulp and various online compressors.

How can i remove elements from the library, minify it, and the result file be smaller than original?

Oam Psy
  • 8,555
  • 32
  • 93
  • 157
  • the angular build process can be found on their [github](https://github.com/angular/angular.js). There's also the build process is [described](https://docs.angularjs.org/misc/contribute)... Maybe it's of use to you – Jorg Jun 23 '14 at 10:13
  • 10
    Is 98KB really such a big deal compared with the effort of having to maintain your own build process and keeping that in sync with mainline just to shave off a few KBs? – Beyers Jun 23 '14 at 18:41
  • 2
    It looks like they are using the Google Closure compiler, along with a bunch of custom stuff. It would be impractical—if not outright impossible—to achieve the same compression without completely duplicating their build process. – OverZealous Jun 23 '14 at 20:27
  • 2
    Just curious: what's the upside of excluding those directives? Do you know what the actual savings could potentially be without them? If it's only a few KB (which I strongly suspect it is), I'd highly recommend leaving them in. Additionally, there's extensibility to consider: what happens if your app specs change and you need to use a directive you excluded? Seems like there would have to be a really compelling reason to warrant going after what you've described. Maybe try optimizing elsewhere? – markthethomas Jun 24 '14 at 22:13
  • 1
    Why don't you serve angular from a popular/performant CDN? You'll gain the likelihood of cache, and probably will outperform your own slightly smaller hosted file anyway. – Matt Way Jun 29 '14 at 00:43

0 Answers0