182 points · by sshroot · 5y ago · 75 comments
Anyway, looking at the docs, my approach wouldn't be as easy in vue-petite. It looks like Components have been functionally gutted. You can still approximate something, but you seem to lose a lot of ecosystem benefits of Vue. Theirs looks great for
Ultimately, this all seems like something coverage and tree-shaking should be able to do. If you're only using 5Kb of Vue, only 5Kb should be bundled. One day, eh? Until then, is the additional 25Kb actually hurting your users?
Not really.
Nor is an extra 30KB font file.
Or an additional 50KB for an icon set.
Or an extra 18KB for a better select box.
Nor is that 200KB header image.
Why not add that 50KB analytics script too?
The extra 40KB for a nice a animation library is useful.
You need to add 150KB for a UI component library.
And so on, all the way until your page is a 2MB download..
Any individual incremental increase can be justified as part of the page weight, but a few KB here, a few more there, and your site suffers death by a thousand cuts. You have to worry about the extra 25KB here and there if you're going to keep the overall size within a sensible performance budget.
In my case, using full-fat Vue lets me do a swathe of complex stuff, pulling in libraries and components we use elsewhere, that also do piles of complex stuff, and it only takes me a couple of hours to progressively enhance a big form, which makes it nicer for the user with pro-active validation, breaking the thing into a wizard, easy dynamic lookups, etc. My work increases conversions, creams KPIs.
Is that worth 30KB? Every day of the week.
Can I batter it down to 20KB? Probably, but it'll take me at least twice as long this time, possibly make the work output less reusable and cost the client twice as much. Is that 10KB worth it? Maybe, maybe not.
Don't get me wrong, I'm not the sort of person who throws JS everywhere. I'm a Django developer who will always push to SSR over SPAs... But I also realise there is occasionally a business case for a but of reasoned splurging. Again, my hope is that within a couple of years tree-shaking gets good enough to automate this nonsense, trim out everything that isn't used.
I always go to Bundlephobia before deciding to use an NPM dependency.
Broadly speaking, I don't disagree. There's a lot of truly awful JS out there, wasting cycles doing things that CSS should be handling, but I think the tooling is slowly getting better.
Also as long as we're talking about Vue, people that have Vue 2 apps and missed the 3.1 release announcement (I don't remember seeing it on HN's frontpage) should check it out, there is a compatibility layer that works really well to migrate progressively.
I started with this post https://blog.ninja-squad.com/2021/06/07/what-is-new-vue-3.1/
Unfortunately the major blocker (for me) is the lack of IE11 support and the bloody paying customers who refuse to move off IE11. One day they'll be gone.
Thus petite Vue can have much smaller size than Vue.
TBH, Lack of ecosystem will be a hurdle here, then again, if you want to leverage multiple other libraries, then you might as well use Vue directly
He also explains some of the Vue optimization tricks like why they ditched the nested JSON and how Vue caches the @click handlers, etc so they don't need to check this on every digest cycle.
I wish there was a free version to link here. Really interesting stuff, shows you how much thought and effort is put in by the creators to optimise so many little things which us users of the framework never even notice is happening.
https://www.vuemastery.com/courses/vue3-deep-dive-with-evan-...
Sorry but it is locked as it's part of the paid course :(
Sounds interesting though, would be awesome if you could give us the gist of how he went about it!
Nice to see an even lighter version optimized for this use-case.
SSR/isometric rendering isn't new, but it's usually hacks around using a frontend JS framework to run the backend and can result in the worst of both worlds. Projects like Blazor (.net) and Livewire (php/laravel) are interesting new solutions to fix this.
That is a general theme, I've found - compared to React, Vue makes the easy things easier, but the hard things harder.
It seems like if you are developing solely to meet "SEO friendly" criteria, you aren't exploring many alternative solutions.
Does all this framework tooling exist to just avoid inspecting a user agent and serving from a different upstream?
Having to maintain a large set of template files, with a dependency on a separate language or framework seems contrary to your premise that Vue is specifically better because it uses "HTML templates by default"
Static typing alone is enough to rule out Vue in my opinion. I even went as far as writing a static type checker for Vue to work around it. It works by compiling the Vue template to a dummy Typescript function that only typechecks if your Vue types are correct.
It found loads of bugs in our code.
But then you are forced to use Javascript on the server side instead of whatever language you are already using. That seems to be a pretty good reason for using Vue as a tool for "progressive enhancement" to me.
For anything else I would most likely use Svelte or maybe React given the right circumstances.
petite-vue is less than half the size of Alpine.
petite-vue has no transition system (maybe this can be an opt-in plugin).
Alpine is developing its own ecosystem and likely will diverge more from Vue in the future. petite-vue aligns with standard Vue behavior whenever possible, so it's less friction moving to standard Vue if needed. It's intended to cover the progressive enhancement use case where standard Vue is less optimized for nowadays.quoted from the link
Now, it may result in an unmaintainable mess in the long run, there is always a threshold for those things.
We initially wanted to use it as a super powered jQuery, then we ended up using Vue as an SPA for part of our app (certain route served a Vue spa to users), now we are going all into the Vue ecosystem for SPA.
I’m a fan of using Vue incrementally, but what you will find is that no editors I have found support Vue inside html templates well. When you use Vue as a jQuery replacement, it gives you some nicety, but it ends having pretty gnarly strings to put html inside of Vue components.
Vue team, if you can get editors to support your string template syntax, that would be killer. Even better, if there was a way to use single file components without the full build step (I.e. bundle up single file components the first time they are needed by a client) and inject that right into the html template that would be amazing.
https://v3.vuejs.org/guide/installation.html#runtime-compile...
For only serving SFCs on request, you can use something like https://vitejs.dev/ during local dev, unless I'm misunderstanding, along with code-splitting.