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

feat: Make loading from an external URL be gated behind a feature. #149

Merged
merged 2 commits into from
Jul 8, 2022

Conversation

a2aaron
Copy link
Contributor

@a2aaron a2aaron commented Jul 8, 2022

attohttpc and its transitive dependencies add a large amount of size to the crate (on the order of about ~400 kB, or about 70 kB when compressed). For applications which don't need external URL loading and are concerned with code size (for example, a WASM binary), this is wasted space. Placing this stuff behind a feature gate allows people to opt-out and reduce code size if they wish.

Note that this doesn't disable loading stylesheets from a local file. It might be worth it to add a feature (something like fs) that also gates that functionality (as this also adds a decent amount of size--about 100 kB compressed and around 500 kB uncompressed). I could pretty easily add this functionality, if desired (I have this functionality on a2aaron:minimal right now).

@a2aaron a2aaron force-pushed the http-feature branch 2 times, most recently from caa9210 to e6a2cad Compare July 8, 2022 19:16
@a2aaron
Copy link
Contributor Author

a2aaron commented Jul 8, 2022

Hm, it looks like the python bindings are failing? I'm not quite as familiar with that stuff, so I might need some help fixing that up.

@a2aaron
Copy link
Contributor Author

a2aaron commented Jul 8, 2022

Ah I see, the bindings just need to have the feature active. There is also a weird failure with pyo3_built in the python bindings, which I think is unrelated to my feature gate.

@a2aaron a2aaron changed the title Make loading from an external URL be gated behind a feature. feat: Make loading from an external URL be gated behind a feature. Jul 8, 2022
@Stranger6667
Copy link
Owner

Thank you for making this PR! Could you, please, rebase? The Python issue is resolved in 0d5311c

`attohttpc` and its transitive dependencies add a large amount of size
to the crate (on the order of about ~400 kB). For applications which
don't need external URL loading and are concerned with code size (for
example, a WASM binary), this is wasted space. Placing this stuff behind
a feature gate allows people to opt-out and reduce code size if they wish.
I'm assumining that these bindings expect `http` to be active. Having
`default_features` be false meant that these bindings weren't getting
the `http` gated code.
@a2aaron
Copy link
Contributor Author

a2aaron commented Jul 8, 2022

Done!

@Stranger6667 Stranger6667 merged commit 137e3ff into Stranger6667:master Jul 8, 2022
@Stranger6667
Copy link
Owner

Awesome! Thanks :)

Re: the file loading feature - I think it also makes complete sense to have such a feature (it could be named file).

@a2aaron a2aaron deleted the http-feature branch July 8, 2022 21:08
@a2aaron
Copy link
Contributor Author

a2aaron commented Jul 8, 2022

Re: the file loading feature - I think it also makes complete sense to have such a feature (it could be named file).

Sure, I can add that real quick. I've opened a PR at #151

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.

None yet

2 participants