Live data from Hacker News

VanJS – A no-JSX framework based on vanilla JavaScript

vanjs.org

81–90 of 178 posts

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#81
post #78

Earlier quoted context omitted.

Try to replicate a sample app made by VanJS with Vanilla JS and check the difference

challenge accepted (app #2, since #1 is just static), BEHOLD: const Counter = () => { let counter = 0; const updCounter = (delta) => { counter += delta; document.getElementById('count').innerText = `♥ ${counter}`; }; document.getElementById('up').addEventListener('click', () => updCounter(1)); document.getElementById('down').addEventListener('click', () => updCounter(-1)); updCounter(0); }; Counter(); *thumbs-up* *th…

The fact that you have to manually maintain the binding between states and UI elements and propagate state changes to UI elements is exactly the thing offered by VanJS, or other popular reactive frameworks (despite with a much larger bundle size)

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#82

Earlier quoted context omitted.

That would be Still more readable than brackets hell like: DoStuff(DoMoreStuff(DoEvenMoreStuff()))

^^^ Apples to oranges: vs DoStuff(DoMoreStuff(DoEvenMoreStuff())) Both of them you would split into indented lines when they become too long. And 1 becomes too long much faster. Also with 2 you can do const todo = DoMoreStuff(DoEvenMoreStuff()); DoStuff(todo); where as with 1 you cannot.

With JSX you can do

  const todo = ;
  {todo}

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#83
post #47

Earlier quoted context omitted.

What are the long term theoretical benefits of vdom? Concurrent rendering?

At least with solid, you can't do `const a = ` without caveats. Instead you have to store it as `const a = () => ` (which isn't quite the same, having problems managing state/renders). In React I was optimizing things by storing vdom in state/memo & then interpolating that exact vdom. Or sharing vdom in multiple places. Without vdom you can't throw jsx results around so haphazardly In solid there's also managing batc…

Your comment signals a key misunderstanding.

Doing a=jsx and interpolation does NOT touch the vdom in any way.

VDOM only comes into play for jsx returned from components before being rendered to screen.

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#84

The whole “small footprint” thing is always weird to me. I understand that lots of people really want to squeeze efficiency out of every single kb but Im struggling to see where this is helpful. A single image, a single pixel from the marketing team, the actual application code, the page, etc are all going to dwarf the framework.

Tangetial: I'm not a huge dwm/suckless guy, but I have it on my Raspberry Pi. I love how instantaneous everything feels. Compared to 14-core, 32GB work laptop running Windows which I will forever loathe because how slow and buggy everything is. Same for websites (e.g. HN, libreddit vs reddit etc.)

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#86
post #78

Earlier quoted context omitted.

challenge accepted (app #2, since #1 is just static), BEHOLD: const Counter = () => { let counter = 0; const updCounter = (delta) => { counter += delta; document.getElementById('count').innerText = `♥ ${counter}`; }; document.getElementById('up').addEventListener('click', () => updCounter(1)); document.getElementById('down').addEventListener('click', () => updCounter(-1)); updCounter(0); }; Counter(); *thumbs-up* *th…

The fact that you have to manually maintain the binding between states and UI elements and propagate state changes to UI elements is exactly the thing offered by VanJS, or other popular reactive frameworks (despite with a much larger bundle size)

Sure thing. But it's also one of those things that comes back to bite you when you least expect it: https://vanjs.org/advanced#why-not-dom-valued-states

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#88
post #78

Earlier quoted context omitted.

Try to replicate a sample app made by VanJS with Vanilla JS and check the difference

challenge accepted (app #2, since #1 is just static), BEHOLD: const Counter = () => { let counter = 0; const updCounter = (delta) => { counter += delta; document.getElementById('count').innerText = `♥ ${counter}`; }; document.getElementById('up').addEventListener('click', () => updCounter(1)); document.getElementById('down').addEventListener('click', () => updCounter(-1)); updCounter(0); }; Counter(); *thumbs-up* *th…

Elements with an id are globals, so you do this (not that it's recommended):

    count.innerText = 
    up.onclick = 
    down.onclick =
etc

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#89
post #60

Earlier quoted context omitted.

Size does still matter. Just because we _can_ serve huge amounts of data over the pipe quickly doesn't mean we _should_.

Except... the huge amount is photos and fonts and whatnot. As you can see on the vanjs size, the biggest framework Angular weights 85 kB and it will be cached. Compared to what Angular also brings in functionality, i don't see size of the framework as an argument anymore. Consider Hackernews: hn.js comes with 21,4 kB. The Y logo on the upper left is a 46,32 kB SVG! What should i care about 1kB minimal framework or 85…

Sure? I was looking in the network tab of Firefox.. Mhh, strange.
Post reply on HN