News for hackers. Stuff that matters.
Re:Designing very large JavaScript applications by jordache on Friday April 20, 2018 @07:05PM (#16889028)
which modern JS framework offers component level lazy loading? Angular offers only route based lazy loading, which as is limited as the article pointed out.
Re:Designing very large JavaScript applications by djhalon on Friday April 20, 2018 @07:17PM (#16889081)
There are different ways to do it based on the transpiler you use. With Webpack and dynamic imports, you could create a custom loader around the promises returned by the Webpack generation.

For React, you can use React Loadable (https://github.com/jamiebuilds/react-loadable) that provides a Higher Order Component and Server Side rendering.

Re:Designing very large JavaScript applications by TheCoelacanth on Saturday April 21, 2018 @12:30AM (#16889984)
Pretty much trivial to implement in react.

    class Loader extends React.Component {
      state = {
        Component: null
      };
    
      componentWillMount() {
        import('./Component').then(Component => {
          this.setState({ Component });
        });
      }

      render() {
        const { Component } = this.state;
        if (!Component) {
          return <div>Loading...</div>;
        } else {
          return <Component/>;
        };
      }
    }
Might want to add a few lines of error handling for production use, but that is pretty much all you need.
Re:Designing very large JavaScript applications by xab9 on Saturday April 21, 2018 @11:14AM (#16891709)
Like the article (presentation) said it's not the best idea to do this with hundreds of components (I think he mentions latency) - in fact you "somehow" have to (should?) bundle things together and then you are back to square one or at least have to hink about pluggability/configuration again.
Re:Designing very large JavaScript applications by TheCoelacanth on Saturday April 21, 2018 @05:07PM (#16893451)
Obviously you don't want to use it for every component, you put it in key places where you want lazy loading to happen.
Re:Designing very large JavaScript applications by ngxoogler on Friday April 20, 2018 @07:32PM (#16889150)
It isn't well documented yet but this is possible in Angular (2+). Here's a good tutorial from someone who figured it out.

https://blog.angularindepth.com/dynamically-loading-componen...

Re:Designing very large JavaScript applications by ggregoire on Friday April 20, 2018 @09:34PM (#16889555)
Re:Designing very large JavaScript applications by k__ on Saturday April 21, 2018 @08:46AM (#16891229)
Re:Designing very large JavaScript applications by darkmarmot on Friday April 20, 2018 @07:48PM (#16889205)
My company's framework lazy loads every component automatically by default (you can override this behavior to batches as well).
Re:Designing very large JavaScript applications by _mrmnmly on Saturday April 21, 2018 @01:40AM (#16890145)
Vue.js has such functionality (when used with webpack & vue-router)
Re:Designing very large JavaScript applications by llamafarmer on Friday April 20, 2018 @07:18PM (#16889091)