Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Consider using jsgo.io for script hosting #1

Open
johanbrandhorst opened this issue Oct 24, 2018 · 13 comments
Open

Consider using jsgo.io for script hosting #1

johanbrandhorst opened this issue Oct 24, 2018 · 13 comments

Comments

@johanbrandhorst
Copy link

Hi!

Good job on this project, the site looks splendid and it serves as a great example of how to use Go and GopherJS, and I imagine it could eventually use webassembly as well.

Anyway, while the script served to me in my testing is around 318K, which is certainly acceptable, I think it'd be interesting to try using jsgo.io to upload and host the scripts, it has some really clever package splitting logic and puts the scripts on Cloudflare. My grpc-web demo site is hosted this way (it also uses myitcv/react): https://grpcweb.jbrandhorst.com.

What do you think?

@myitcv
Copy link

myitcv commented Oct 24, 2018

Yes, great work @housseindjirdeh!

@johanbrandhorst as we discussed on Slack, it looks, from my very amateurish investigation, like https://gohackernews.com is being served via Fastly so I'm not sure there would be any benefit from the CDN-aspect of jsgo.io. Indeed because of the package splitting, the overall size might, as you mentioned, increase slightly.

@housseindjirdeh
Copy link
Contributor

Thanks so much folks, means a lot :)

I stumbled on jsgo.io a while ago and have been meaning to give it a shot (cheers @dave for building it) but also wondered if it would make much of a difference in performance. If there was a way to defer loading some of the packages that are split, that would be amazing but I don't think that's possible 🤔

@dave
Copy link

dave commented Oct 25, 2018

Ha loading packages at runtime is definitely possible... I ran some tests a while ago... it’s pretty complex though because you need to get the dependencies for the new package minus the ones you already have. It worked though. I’m going to use this technique for loading editors at runtime in github.com/dave/frizz

@dave
Copy link

dave commented Oct 25, 2018

I was looking at converting this project to jsgo but got stuck with all the node build stuff. I stay away from node unless absolutely necessary 😉

@housseindjirdeh
Copy link
Contributor

Aha that's my fault, there really was no reason for me to include the Node build stuff (I might use it to hook into a CI later but it's not necessary for folks to know to get this project up and running). Updated the README.

Definitely going to keep an eye on frizz. Loading the correct packages at runtime would be an amazing thing to see 😍

@myitcv
Copy link

myitcv commented Oct 26, 2018

@housseindjirdeh

If there was a way to defer loading some of the packages that are split, that would be amazing but I don't think that's possible

Is this a problem at the moment?

What impact would you expect the deferred loading to have?

@dave
Copy link

dave commented Oct 26, 2018

Got it working!
https://jsgo.io/dave/go-hackernews

Recompile here:
https://compile.jsgo.io/dave/go-hackernews

Source:
https://github.com/dave/go-hackernews

@housseindjirdeh
Copy link
Contributor

@myitcv Not necessarily a problem, just looking for ways to improve performance where possible. The bundle sits at 318 KB gzipped so it isn't the smallest app in the world. Code-splitting and lazy loading/deferring any packages if possible might just help.

But there also things that can probably be solved upstream that might make this a non-issue, such as better dead-code elimination.

@housseindjirdeh
Copy link
Contributor

Nice one @dave! Total bytes sent did increase slightly which was expected, but still pretty cool to see :)

@dave
Copy link

dave commented Oct 27, 2018

Yes with a cold cache the jsgo page will be a bit bigger, because it has to disable DCE (dead code elimination). The benefits come when you deploy a new version of your app, and your end users only have to download the JS for the packages that have changes. The go-hackernews app is pretty small so on a fast connection there wont be much of a difference, but as the app gets more complex (e.g. https://play.jsgo.io/ is ~2MB of JS) or with a slower connection it becomes more of a benefit.

@dave
Copy link

dave commented Oct 27, 2018

BTW if you really wanted to optimise the performance of jsgo, you could take the contents of the loader js and add it to your index page. This would change on every deploy though, so tricky to get into a deploy pipeline.

@dave
Copy link

dave commented Oct 27, 2018

Also, jsgo could probably do with some additions to support things like the preload and dns-prefetch preconnect hints you have in your HTML.

@housseindjirdeh
Copy link
Contributor

housseindjirdeh commented Oct 29, 2018

Agreed, there's always the benefit of being able to preload the more critical packages when they're split up and things are more granular 👍🏾

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants