This Lesson is for Members

Subscribe today and get access to all lessons! Plus direct HD download for offline use, enhances transcripts, member comment forums, and iTunes "podcast" RSS feed. Level up your skills now!

Unlock This Lesson

Already subscribed? Sign In


    Lazy Loading non-Angular Libraries with ocLazyLoad

    John LindquistJohn Lindquist

    ocLazyLoad will also load non-Angular libraries in the lazy way.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson


    00:00 Now, I want to add the date to the store template that I've loaded in. I'll say Store.Date, and then I'll just pay some Moment code, Moment's a great library for formatting and showing dates. Then, I'll go into my HTML here.

    00:14 We'll make it an H2 and do Store.Date. Then you suddenly realize that, "Wait a second. I haven't loaded in this Moment library yet. How am I going to do that? This is in a loaded-in module. Do I have to go back and add it all the way into my index HTML?"

    00:31 The answer is "No. You can simply load in any library by just passing it in." I'll use a live template here for a moment and just load in Moment. You can see, once I refresh, hit Click Me, that it formats and displays the date.

    00:46 If you check out the network tab, you can see that Moment, once I refresh, is not loaded up front in any of these, but once I hit Click Me, that Moment is the last thing loaded. It loads in the store and the cart in Moment and everything. It satisfies all those dependencies for you.