6

Friday I spent some time refactoring an AngularJS application that I've been working on for the last few weeks. My refactoring centered on 4 pretty specific areas:

  1. wrapping all of my AngularJS code in IIFEs,
  2. rearranging my controller code so that I eliminated virtual functions in favor of assigning functions to members by the same name in my controller,
  3. cleaning up any issues by adding "use strict;" to all of my js files in the appropriate places and
  4. eliminating the use of a global app variable. All went well and introduced fewer issues than I originally expected.

After I completed the above work, I was astonished by the performance boost it apparently gave my app. The app uses Angular Material fairly heavily and the AM components that seemed to be somewhat sluggish were noticeably snappier. Is this type of performance boost to be expected?

Tushar
  • 85,780
  • 21
  • 159
  • 179
Mike Feltman
  • 5,160
  • 1
  • 17
  • 38
  • Not sure why, but it does sound interesting! – Pepijn Sep 26 '15 at 16:01
  • 1
    My hunch for this performance boost is the use of 'use strict'... http://stackoverflow.com/questions/3145966/is-strict-mode-more-performant. – bengro Sep 26 '15 at 16:24
  • Yes, avoiding global variables, avoiding things that strict mode doesn't like, and directly referencing functions can definitely improve performance. – Bergi Sep 26 '15 at 16:34
  • 3
    I really don't understand why this question is considered too broad. I provided some relevant background info and then literally asked as yes or no question. – Mike Feltman Sep 26 '15 at 20:33

0 Answers0