0

Is it anyhow possible to trigger trigger angular 2 router to preload a lazy loaded module on mouseover and route to it on click to make a large app more responsive?

Manuel
  • 9,112
  • 13
  • 70
  • 110

1 Answers1

2

Yes it's possible.

Based on your configuration, if it's webpack or SystemJS, you can load the module beforehand and then do what ever you want to .

This is the proper answer :

How to manually lazy load a module?

if you're using webpack , you need to install bundle-loader , and then you can easily require files!.

So for SystemJS :

this.loader.load('./src/test.module').then((factory: NgModuleFactory<any>) => {
  console.log(factory);
});

And for Webpack

let file = require('./src/test.module');

  console.log(file);

.

Community
  • 1
  • 1
Milad
  • 27,506
  • 11
  • 76
  • 85
  • I think your linked answer refers to systemjs. I have an angular-cli bootstrapped project with Webpack. – Manuel Dec 20 '16 at 21:09