Search code examples
jqueryangularlazy-loadinglazy-evaluation

How to lazy load jquery for Angular app , In order to reduce first request size?


I am building an angular app .In one of its module ( a component of it : We need to use existing written jquery code ) . I am thinking of loading it lazily ? Is that possible ?


Solution

  • As mentioned in the comments it is normally not needed, everything you do with jQuery in that template you could do with js/ts in your angular component code... But if you have to use jQuery for some reason just load it in that component code (on init or after view init) in which you need it. So it will get lazy loaded when that component is called... Do not put it in app component!