News for hackers. Stuff that matters.
Re:Plain Vanilla Web by giancarlostoro on Sunday May 11, 2025 @02:25PM (#43955796)
Even so you can do insanely simple refreshing dynamics with CSS and JS without importing any npm packages.
Re:Plain Vanilla Web by cmonBro22 on Sunday May 11, 2025 @02:38PM (#43955945)
Sure, but the runtime is not exactly designed to guide you to the best way to do this. Hence the prevalence of frameworks to paper over the runtime.

I openly admit that I'd rather learn a new framework than touch anything to do with figuring out how the browser is intended to behave in practice. What an abomination and insult to humanity.

Re:Plain Vanilla Web by esseph on Sunday May 11, 2025 @03:27PM (#43956358)
Oh no, you're part of the problem :(
Re:Plain Vanilla Web by cmonBro22 on Sunday May 11, 2025 @05:21PM (#43957263)
yes, probably, even maybe

But what's the problem again?

Re:Plain Vanilla Web by esseph on Sunday May 11, 2025 @08:52PM (#43958634)
"Nobody knows how to do anything and shit is inefficient and slow and why does all of this software suck" - customers of things built using frameworks but no understanding of the system being abstracted
[dead]
Re:Plain Vanilla Web by int_19h on Monday May 12, 2025 @08:04AM (#43962051)
Backwards compatibility, which is kinda important on the web. It should be possible to build a website and have it just work a decade later.
Re:Plain Vanilla Web by hdjrudni on Sunday May 11, 2025 @03:09PM (#43956194)
Huh? The built-in APIs aren't perfect, but we're talking about something simple as

``` fetch('/my-content').then(async res => { if(res.ok) { document.getElementById('my-element').innerHtml = await res.text(); } }) ```

Something like that. Doesn't get much easier. Gone are the days of browser inconsistencies, at least of you stick to "Baseline Widely available" APIs which is now prominently displayed on MDN.

Re:Plain Vanilla Web by rhet0rica on Sunday May 11, 2025 @04:05PM (#43956694)
No-framework web tinkerer here. If I had a nickel for every second of my life I've spent typing document.getElementById, I'd be able to afford new fingers. Should've been renamed to getId() and put in global scope two decades ago, if not three. At least querySelector() is a few characters shorter, but I always feel bad using such an alarmingly overdesigned tool for anything trivial.
Re:Plain Vanilla Web by pests on Sunday May 11, 2025 @04:13PM (#43956765)
You don’t have to call getElementById or querySelector on document. You can narrow the search by starting at a specific node, just most people default into document as it’s already a global.
Re:Plain Vanilla Web by someothherguyy on Sunday May 11, 2025 @05:24PM (#43957289)
> You don’t have to call getElementById or querySelector on document.

You do have to call `getElementById` on a document. There can be many documents in a window.

Re:Plain Vanilla Web by pests on Sunday May 11, 2025 @05:37PM (#43957372)
Ah yes correct on getElementById, especially as every id must be unique.
Re:Plain Vanilla Web by Jaygles on Monday May 12, 2025 @12:17AM (#43959604)
> especially as every id must be unique.

Although a very consistent convention, there are no guardrails put in place to prevent something from setting the same id on two or more elements.

getElementById will return the first element that it finds with the id, but you can't know for sure if it is the only one without additional checks

Re:Plain Vanilla Web by insin on Sunday May 11, 2025 @04:26PM (#43956863)
If I'm just adding sprinkles of interactivity to a statically-rendered page for something that vanilla is good enough for (i.e. minimal-to-no display logic), I use the expando giving an element an `id` adds to `window`:

    <textarea id="userNotes"></textarea>
    <button type="button" id="copyButton">Copy</button>
    <script>
    copyButton.addEventListener('click', () => {
      navigator.clipboard.writeText(userNotes.value)
      copyButton.innerText = 'Copied'
      setTimeout(() => copyButton.innerText = 'Copy', 1000)
    })
    </script>
Re:Plain Vanilla Web by someothherguyy on Sunday May 11, 2025 @05:19PM (#43957246)
Why are you writing it so many times? Write an alias in 10 seconds?

function getId(v) {return document.getElementById(v)}

Dev tools allows $ $$, dunno, make a macro?

Re:Plain Vanilla Web by rhet0rica on Sunday May 11, 2025 @06:49PM (#43957899)
But if Brendan Eich wanted us to have a shorter name, he would have given us a shorter name!

We must not defy the system!

Re:Plain Vanilla Web by BrendanEich on Monday May 12, 2025 @03:10PM (#43966516)
As I said to Lex Fridman, I was influenced by AWK. Ragrets!
Re:Plain Vanilla Web by cmonBro22 on Sunday May 11, 2025 @05:37PM (#43957370)
Sorry?
Re:Plain Vanilla Web by akoboldfrying on Sunday May 11, 2025 @09:16PM (#43958755)
JavaScript has functions:

    const g = (x) => document.getElementById(x);
Re:Plain Vanilla Web by kentbrew on Monday May 12, 2025 @02:37AM (#43960213)
That's a code smell. If you're creating the element you ought to already know about it. If you're not creating the element you should inventory them all at once as the page (or component) loads.
Re:Plain Vanilla Web by cmonBro22 on Sunday May 11, 2025 @05:35PM (#43957361)
...what is this simple compared to?
Re:Plain Vanilla Web by andrewflnr on Monday May 12, 2025 @01:08AM (#43959821)
I guess openly admitting that you refuse to learn how your platform actually works is an "earnest approach", of a sort, but so is admitting that you routinely leave grocery carts in the parking lot and don't see a problem with it.
Re:Plain Vanilla Web by giancarlostoro on Tuesday May 13, 2025 @07:49PM (#43979162)
Theres even an insane amount of documentation on the web about the web. MDN is very well maintained to boot. Im not as versed as some on front end web, but I recognize that I can slice through a lot of front end stuff by just referring to MDN.
Re:Plain Vanilla Web by al_borland on Sunday May 11, 2025 @10:47PM (#43959185)
I have a few sites that aren’t that complex, and I use JS to run a PHP file and populate the results in a div. It appears reactive, but it’s dead simple.

I get that huge apps probably need a lot more than that, but so many people these days reach for heavy frameworks for everything, because it’s all they know.