async bundle loading

60 views
Skip to first unread message

stagas

unread,
Apr 24, 2014, 5:39:58 PM4/24/14
to compo...@googlegroups.com
Hi all,

I'm having this issue and I thought someone might have some solution in this group.

I have some quite big components in a SPA that I'd like to be loading on-demand into the page. I don't want to give up CommonJS but also I don't want to be loading everything on initial page load. Usually this has never been an issue to me, but these are really big and plenty, think megabytes each including the assets. It would also be nice to share with those bundles some of the things that load on the init bundle, to reduce their size, but they don't need to be sharing with each other. It's just what's loaded already + the extra stuff and assets of their own.

How would you deal with this?

William Casarin

unread,
Apr 24, 2014, 7:16:16 PM4/24/14
to compo...@googlegroups.com
I guess the native analogy is dynamically linked libraries. I imagine
doing something similar in the context of component would be somewhat
complicated.

One solution would have the "dynamically linked" libraries register
themselves on some global object, and have the require reference that
object. Then you would need some way to specify which libs are dynamic
in the component.json. Then you could have a custom builder build a
separate .js file for the dynamic shared libraries.

Kind of crazy but I imagine you could do it with a custom builder.

I have a feeling spdy + es6 modules would make this easier...
> --
> You received this message because you are subscribed to the Google Groups
> "component" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to componentjs...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Jonathan Ong

unread,
Apr 24, 2014, 9:47:08 PM4/24/14
to compo...@googlegroups.com
split your builds into bundles using https://github.com/component/bundler.js. then inject script tags with the appropriate bundles. that's what i do. lol

for more complicated stuff though, you're eventually going to need a requirejs kind of thing going on.

George Stagas

unread,
Apr 25, 2014, 5:02:36 AM4/25/14
to compo...@googlegroups.com
Jonathan it looks like what I needed! I also was thinking of injecting script tags that way, I just wasn't sure how to share deps with boot, this seems to be doing that. Great!


Reply all
Reply to author
Forward
0 new messages