Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hello there, I want to start by saying that this library looks absolutely lovely and powerful, and I really appreciate the work you did.

I was comparing the HTMX and Unpoly and found it almost in every aspect win against HTMX. But one thing I noticed is the current base size of the library: 48.7 KB gzipped. While Unpoly is relatively small it's still pretty big in comparison with: HTMX is ~14k min.gz’d, Alpine is ~10k min.gz'd, React + ReactDOM is ~45k min.gz'd, Vue 3 is ~35k min.gz'd.

So my questions are these:

  1. Is it possible to not connect some features of Unpoly like loading-indicators, etc.?
  2. Is it possible to optimize the package size of Unpoly and why is it relatively big in comparison with HTMX?

P.S.: I know that size optimizations are probably not on the list of first priority, so I just want to know the thoughts of the team.

You must be logged in to vote

Replies: 3 comments · 2 replies

Comment options

Hi @enfipy, welcome to the forums.

why is it relatively big in comparison with HTMX?

They are really quite different libraries once you go beyond the basic HTML-over-the-wire concept. Here are some differences that affect file size:

Category htmx Unpoly
API style small low-level API large high-level API
Design priorities worse-is-better the-right-thing
Extensions small core, many extensions batteries-included, few extensions
JS internals functions classes (which don't minify well)
Defaults unopinionated, code your own defaults strong defaults included, convention over configuration

Is it possible to not connect some features of Unpoly like loading-indicators, etc.?

Most of it is batteries-included. Currently the only optional features are unpoly-migrate.js, unpoly-jquery.js, unpoly-bootstrap.js.

We may offer some way of plugin system in the future, although it's not a priority.

It should be noted that plugin system is not free in terms of complexity an will increase the file size of the full system. All code needs to handle a plugin being both present or absent, and plugins still require code in the core to integrate. E.g. when "animation" is an optional packages, all other packages still need to handle the fact that fragment updates might be async, ignore fragments in an exit animation, etc.

The progress bar is actually an example that could be extracted quite easily, because it only uses existing events and has no other integrations with the rest of the library.

React + ReactDOM is ~45k min.gz'd

Again with the caveat of comparing things that are fundamentally different, but a typical React app is going to bundle more than that (Router, API client, state management, styling solution, etc.).

You must be logged in to vote
2 replies
@enfipy
Comment options

Hey, thanks for a quick and complete response!

One thing I want to mention, and why I brought up this topic in the first place that are some applications (like simple landings, blogs, simple admin tools, etc. with basic HTML-over-the-wire™) don't need much more than simple HTML replacement, or better form validation. But still would like to benefit from Unpoly ergonomic design and speed.

I don't say that 50kb is too much for a website library (it's not), but I want to bring up perhaps a more philosophical question - will Unpoly continue to add new awesome features and grow in size for the core library? Or maybe you have plans to make some approach as Svelte did with their ahead-of-time compilation. Or split the core library into some necessary parts (like @vue/runtime-core) and "batteries".

I don't want to be "that guy" who only screams about bundle size but I also see a lot of marketing advantages to providing more information about your design principles and explaining why Unpoly is making a little bit more bundle footprint but better for developers.

Anyway, I still will choose Unpoly over HTMX just because of module up.layer.

@triskweline
Comment options

will Unpoly continue to add new awesome features and grow in size for the core library?

Hard to predict the future. Currently my focus is fixing edge cases in the functionality that is already there.

Or maybe you have plans to make some approach as Svelte did with their ahead-of-time compilation.

We're definitely not going to write a compiler 😄

Comment options

The loading indicator was a (IMHO) great default UX experience improvement. I could see it as a plugin, but I think it would be a net negative overall since I suspect it's not contributing that much to the overall bundle size.

Henning outlined the bundle sizing a lot more beautifully than I think I could have. For many of the applications I build, they don't grow much more than Unpoly + a handful of compilers.

Not to say that we shouldn't concern ourselves with bundle sizing and optimizations, but if I do happen to bring in other libraries to my application, Unpoly sits about middle in terms of sizing.

Example: js.stripe.com/v3 is 156kB gz'd, and stimulus.umd.js is 13kB gz'd.

You must be logged in to vote
0 replies
Comment options

many thanks for bringing up this discussion and all the thoughts in the answers.
Since we are also looking heavily into the topic size and speed and with this into the possibility of deferred/ lazy loading as many things as possible,
I just want to link to this discussion, since its adding another part to the complete picture (thus it's not directly about the size of the js):
Lazy loading, frames, "inline" layers? #350

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
💡
Ideas
Labels
None yet
4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.