Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share more init work #1670

Merged
merged 2 commits into from
Aug 23, 2018
Merged

Share more init work #1670

merged 2 commits into from
Aug 23, 2018

Conversation

Rich-Harris
Copy link
Member

Change suggested by @tomcon — we can move more initialisation work into shared functions. The reason it's the way it is currently is to avoid adding extra code for components that don't need it, but realistically this just makes the typically app larger for the sake of sometimes making standalone components smaller.

Taking the realworld app as an example, this PR reduces the total JS size to 157,336 bytes from 160,200, a 1.8% reduction. (Granted, after zipping the difference is almost zilch — 34141 from 34145 — but that's after concatenating all the code-split chunks, and in any case minimising the JS that needs to be parsed and eval'd is the larger goal.)

Compiling a standalone <h1>hello {name}</h1> component goes up from 2,391 to 2,469 bytes, a 3.3% increase. That's a more 'visible' increase for someone evaluating Svelte for the first time, but maybe that's ok?

@ekhaled
Copy link
Contributor

ekhaled commented Aug 21, 2018

Please also check HMR works with this change.
I have a feeling it still will. But if it doesn't, maybe I can prepare the helper for this change

@Rich-Harris Rich-Harris merged commit 3778431 into master Aug 23, 2018
@Rich-Harris Rich-Harris deleted the init branch August 23, 2018 02:23
@Rich-Harris
Copy link
Member Author

Tried it out in sapper-template — HMR looks good 👍

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

Successfully merging this pull request may close these issues.

2 participants