![]() Updated Gruntfile to uglyfy, renamed file name and updated references in the final.Added a reference of ocLayzLoad and updated JS files reference to load on demand from app.js or. ![]() Since my problem was conversion of existing application to lazy load it’s modules, I created a fresh AngularJS project using Yeoman generator and applied my changes to the generated file. Hat tip to Olive for pointing me in the right direction. Armed with this knowledge, I experimented converting Yeoman based AngularJS project to lazy load it’s components. I was still mulling over it but was finally convinced when I read the following thread on stack overflow: OCLazyLoad registers the modules and components with AngularJS dynamically. I found OCLazyLoad bower component was addressing this problem. In the above code, we have used the angular ngStyle attribute directive to set a background-image to the div element. AngularJS with ocLazyLoad ( ): My requirement was to load first page quickly and load the remaining JS files on demand.Also after using RequireJS, the main.js file grows to ~500kb. AngularJS does not allow registration of modules and components after initial bootstrapping of angular app and so RequireJS could only load javascript files but it could not register new angular modules and components on demand. AngularJS with RequireJS: There are many generators available on the web to use RequireJS with AngularJS but they do not solve issue of on-demand loading & downloading of AngularJS modules and components registering problem.While working on a SaaS app, I was faced with a challenge where the first page, which included large minified JS file, was taking time to load. In this blog entry I have attempted to show you how to convert AngularJS yeoman based Single Page Application (SPA) to lazy load or download file on demand with minor modifications to code. With Tenor, maker of GIF Keyboard, add popular Loading Transparent Gif animated GIFs to your conversations. Load faster: Convert your existing yeoman based AngularJS 1.x application to lazy load
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |