ocombe / ocLazyLoad

Lazy load modules & components in AngularJS
https://oclazyload.readme.io
MIT License
2.63k stars 510 forks source link

Load a directive using oc-lazyLoad #304

Closed iankit3 closed 5 years ago

iankit3 commented 8 years ago

Can i Lazy-Load a directive as in picture 1 2

My code is not Modular so i want to lazy load the directive itself Is it Possible ? Or i should make my code modular first and try lazyLoad the modules

ghost commented 8 years ago

The goal of ocLazy is helping you "lazy load FILES" . Once you have loaded the js files, you can use any things from the files (Ctrl, directive... )

If you have just a few js files and small code base, don't bother with oclazy

giang12 commented 8 years ago

^ split those 1500 lines into their own respective files then. there are no magical ways to only pick X lines from a file from server. Or maybe im wrong, maybe you know the magic lol. To be Frank (Ocean), if you are not modularizing, why even bother with angular

giang12 commented 8 years ago

just gonna put this here https://scotch.io/tutorials/angularjs-best-practices-directory-structure and you rather spending "Time" searching for a lazy, non-existent magic, rather than spending the "TIMe" to understand the code base to make it more efficient, you do you m8. See what approach save you more "Time", peace

giang12 commented 8 years ago

well since your time is so damn precious, let's see directive life circle

  1. .compile($element, ...)
  2. .controller($element, $scope, ...)
  3. .preLink($element, $scope, ...)
  4. .link($element, $scope, ...)

I bet at this point in time, your "complex" app doesnt even need prelink and link, maybe even compile...

split your 1500 lines (it's not that many really), into reusable parts -> load them via dependencies, in order... eg: load necessary controller for a directive, then load the said directive -> that way the controller is reusable. damn that takes so much "time"

giang12 commented 8 years ago

then you will ask, how to load them in order, damn im glad you ask...now you move into a module management...eg commonjs, or requirejs, or roll out your own...that will require more "time", so i guess you wont need them