17 ms·
A little bit of plain JavaScript can do a lot
- dhritzkiv 6y agoMore specifically, how JavaScript can do a lot in browser by interacting through the DOM API. The modernization of the DOM API in the last 5 years has done a lot to remove the need for jQuery et al, and has made building the View part of JavaScript apps much more frictionless.
- ed25519FUUU 6y agoWhere can we learn about this “modern JS“? I feel like in some ways I’m learning the old ways, similar to old c++.
- bartread 6y agoThe parent isn't talking about JS: they're talking about the DOM APIs. The best resource I've found for learning about these is MDN: https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model https://developer.mozilla.org/en-US/docs/Web/API/Document_Ob.... I've found this to be an incredibly helpful reference when I need to do something without using a library.
- zamadatix 6y agoFollowing the tc39 proposals on GitHub is a great way to keep up with features just being added. "What's new in ES2020" type blog posts should catch you up between then and the bleeding edge. MDN for actually getting the technical details on things as you try to implement the features you read about (will also xover browser specific APIs). caniuse to see if they are actually ready to be used.
- monoideism 6y agoIt's both modern Web APIs as well as ES6 JavaScript, both of which make working in VanillaJS quite pleasant. If you don't need to support older browsers, you don't even need to use any packaging software (although if you're building a serious app, it's still wise to do so). You can import ES6 modules in vanilla JS, and a modern browser will do the loading for you. Great for quick starts.
- dmitriid 6y agoYou still end up re-implementing half of jQuery. Because element creation is just as much passion as it was in 1999. Because useful functions are limited or stunted compared to jQuery counterparts (querySelectorAll returns a weird object instead of an array and throws exceptions if you as as much as as look at it funny, etc.).
- clairity 6y agoha, i just went through this today, querySelectorAll returns a NodeList, which is static rather than live, requiring you to iterate through the list rather than acting on the elements directly. but it's nice that jquery (as convenient as it is) is no longer a must-have library for dom manipulation.
- runarberg 6y agoEither iterate through the `NodeList` with a `for ... of` loop or a `.forEach` method, or convert it to an array using `Array.from()` or `[...nodeList]`. `NodeList` can be a live list (not `querySelectorAll` though) which has some benefits over arrays. `NodeList` also implements `Symbol.iterator` so you can use your favorite iterator library if you need to map, filter or reduce it. And with the future pipeline operator, you’ll really don’t see a different between a standard array and a fancy structure like `NodeList`.
- dmitriid 6y agoYou just spent three paragraphs describing how NodeList is different, including a reference to a non-existent operator. Nice.
- hombre_fatal 6y agoWell, you called it a "weird object" that throws errors if you "look at it funny." They tried to demystify it for you in just three sentences. That jQuery lets you willfully cling to the corpse of familiarity instead of spending 30 seconds looking up what NodeList was years ago says more about you than anything about jQuery. And with your end-cap comment about the pipeline operator that they were already, helpfully, pointing out was going to be introduced in the future, you just sound like sour grapes. What gives? Kind of a weird attitude to bring to a forum of craftspeople.
- jv22222 6y ago@op Nice! Might be good time to also mention these sites: http://microjs.com/ http://microjs.com/ http://youmightnotneedjquery.com/ http://youmightnotneedjquery.com/
- rishav_sharan 6y agoThis is another great resource for vanillajs snippets https://htmldom.dev/ https://htmldom.dev/
- mqus 6y agohttp://vanilla-js.com/ http://vanilla-js.com/ http://vanillajs.net/ http://vanillajs.net/
- identity0 6y agoIt’s a little funny seeing vue/angular/react/whatever people discover vanilla JS. I thought classList, innerHTML, and querySelectorAll were all extremely common knowledge.
- monoideism 6y agoIf I'm not mistaken, she's a systems programmer. More low-level stuff. She's definitely not a frontend/React/vue.js dev, as she says in the article. She's written some excellent articles on lower-level programming. But I agree that VanillaJS is not appreciated by a large number of web developers.
- bitwize 6y agoThat's because in order to build anything of any remote sophistication, you need a framework, otherwise you are committing to maintaining an unmaintainable spaghetti mess. Just like nobody actually built Windows applications with just the Windows API -- they all used frameworks like MFC or reimplemented those frameworks in-house.
- goatlover 6y agoExcept for the stuff everything else runs on top of like operating systems, servers, runtimes and browsers.
- bigiain 6y ago> in order to build anything of any remote sophistication, you need a framework Sure. But does the project/requirement described in the original article sound particularly sophisticated? I note that HN loads less that 150 lines of js and no framework. While there's an argument to be made that this place's frontend code is "not remotely sophisticated", it without doubt provides a huge amount of value anyway. While I agree with everybody here about the requirements for good frameworks (and good development practices) for complex or sophisticated web applications, to me at least it's abundantly clear the author of the article made the correct choice for her problem domain. Some things should resist every effort to make them more complex or more sophisticated than they need to be. Most things probably. "Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery I strongly believe that, while he did not know it at the time, he was totally talking there about lines of code. Bill Atkinson clearly took that philosophy to heart: "He was just putting the finishing touches on the optimization when it was time to fill out the management form for the first time. When he got to the lines of code part, he thought about it for a second, and then wrote in the number: -2000." from: https://www.folklore.org/StoryView.py?story=Negative_2000_Lines_Of_Code.txt https://www.folklore.org/StoryView.py?story=Negative_2000_Li...
- _hardwaregeek 6y agoThis is super super minor but it's JavaScript not Javascript. IMO the camel case makes it look so much better :D
- kagenouta 6y agoIf we're nitpicking, it's Pascal case when it starts capitalized :-p
- kevincox 6y agoI'd paint that bikeshed UpperCamelCase.
- dmitriid 6y agoIf you really want to nitpick, it's ECMAScript
- quickthrower2 6y agoIt should be javaScript
- wolfgang42 6y agoI agree about the nuisance of creating DOM elements. innerHTML is OK if you’re doing static content, but for anything that needs to be dynamic (untrusted input, event handlers, etc.) I have a little tiny helper library that I carry around in my head and write into projects that need it: const $T = text => document.createTextNode(text) function $E(tag, props, kids) { const elem = document.createElement(tag) for (const k in props) { elem[k] = props[k] } for (const kid of kids) { elem.appendChild(kid) } return elem } (Add flourishes as necessary for things like optional arguments and allowing falsey kids.) This isn’t as nice as JSX, but it makes a reasonably ergonomic API for quick little projects. Here’s what the example in the article would look like (admittedly it’s a bit easier to follow with syntax highlighting): const button = $E('button', {}, [ $E('i', {className: 'icon-lightbulb'}, []), $T('I learned something!'), $E('object', {data: '/confetti.svg', width: 30, height: 30}, []), ]);
- ihuman 6y ago$E is pretty close to React.createElement, which JSX's tags compile to https://reactjs.org/docs/react-without-jsx.html https://reactjs.org/docs/react-without-jsx.html
- wolfgang42 6y agoI’m not surprised by the convergent evolution—it’s the obvious API for creating elements. (My earliest versions of $E had arguments (tag, kids, fn) and would call fn(elem) so it could perform arbitrary modifications on the node, but I eventually realized that all I ever did was set properties and it was silly to have an entire lambda just for that.)
- hn_throwaway_99 6y agoThis is fairly similar to hyperscript: https://github.com/hyperhype/hyperscript/blob/master/README.md https://github.com/hyperhype/hyperscript/blob/master/README....
- fiddlerwoaroof 6y ago
- galaxyLogic 6y agoAn interesting use of 'classList' is that it makes it easy to use css-classes to indicate the state of a dom-element. Is the element selected or not? Well does its classlist include the css-class 'selected'?
- atoav 6y agoThis is a good approach as it helps you solve a lot within CSS. Want to show the subpages of a selected menu point? Just use a css selector which changes their display state.
- edwinjm 6y agoDo not use classes to mark something as selected. People using screen readers won't know whether something is selected. Use aria attributes like aria-selected instead. https://www.w3.org/WAI/PF/aria/states_and_properties#aria-selected https://www.w3.org/WAI/PF/aria/states_and_properties#aria-se...
- xg15 6y agoSo, question for those who are following the JS ecosystem trends more closely: Is innerHTML now officially "ok to use" again? I remember way back (when XHTML was still on the table) that innerHTML was effectively deprecated: It was still around but you weren't supposed to use it for anything new because support might be dropped at any point in "the future". It was also non-standard. Instead, you were supposed to use the DOM APIs (createElement etc) for any kind of DOM modifications. (Not even talking about the risk of performance issues or XSS vulnerabilities if you used innerHTML naively) Now "the future" has come around and innerHTML is still supported basically everywhere. It's clear that implementing innerHTML correctly adds substantial complexity to browsers (they have to parse and serialise arbitrary HTML fragments on the fly, synchronously, without stalling the event loop. The result also has to interact well with all the other DOM manipulation/inspection APIs. Not to mention if the HTML string contains its own bits of JS...) - however, there seems to be so much "legacy" content that dropping the API seems infeasible. So, does anyone know what the official state of innerHTML is in terms of standard compliance and future support?
- IshKebab 6y agoWhether or not it is widely supported is academic - you shouldn't use `innerHTML` for the same reasons you shouldn't use `eval`, the most important being that it is a security risk.
- yunruse 6y agoThe DOM draft [1] seems to include it. Legacy content is better slow than unusable, however, so it’s better off being discouraged – by linters, dev docs and a warning in the console. FWIW, this is currently linted in TSlint but not JSlint. It would be nice to have this (via regular or template strings) compile to DOM objects, wrapped with a couple of pointers indicating where strings or elements are placed. I guess for now the best course would be to budge that into transpilation, raising an error if it does anything kooky like work at the boundaries of elements. (.innerHTML setting is sugar for a HTML parser being initialised on the element, so such a transpiler wouldn’t be removing functionality per se) [1] https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
- 6y ago
- blackrock 6y agoInstead of HTML, can’t JavaScript just be used to paint the browser canvas? You can create your text boxes, your drop downs, buttons, etc., everything that makes it a GUI application. Then you fetch your data, per the page you display, via JSON, and fill in the fields. The initial JavaScript download is heavy, but the normal usage of the web application should be quicker, as you’re only fetching the relevant data to fill each of the required widgets. This does sound resource intensive, for computers back in the 1990s, but today’s iPad, iPhone, and modern laptop computers should be powerful enough to handle it. Or did I just describe some already popular JavaScript framework?
- anonytrary 6y agoI think you just described the browser. While there are some efforts to do canvas-only rendering in JS, they aren't mature and are meant for specific use-cases like game boards and stock charts. For a typical website, this approach would likely have negative implications for your site's accessibility and usability; the site would also be harder to index.
- blackrock 6y agoThat’s correct. I was thinking more along the lines of video games and interactive stock charts. But as an easier way to develop GUI applications via JavaScript. Perhaps where the widget definitions are described via an easier, LISP like syntax, and rendered by the Framework. Kind of like Emacs Lisp. Actually, it might have been amazing if the original Netscape browser shipped with a Emacs Lisp like scripting tool to begin with. But instead, we got JavaScript.
- gear54rus 6y agoYou described an SPA. Fetch relevant data and render to controls. Not sure why we need canvas for that.
- blackrock 6y agoYou are correct. I just inadvertently re-invented React.
- userbinator 6y agoI’ve never worked as a professional frontend developer, so even though I’ve been writing HTML/CSS/JS for 15 years for little side projects, all of the projects have been pretty small I'm pretty much the same, and one thing I've noticed which continues to both amuse and sadden me is the fact that those whose main focus is not web development often make better sites/pages than "professional" developers. I once rewrote, in a few hours, an internal site that had been developed by another team over a few weeks but with many problems (it was an enormous SPA), and made it so much faster and easier to use that once my coworkers found out, they all switched to using mine. That didn't go over well with the team who built the original... Another experience I've had with a dedicated frontend developer: https://news.ycombinator.com/item?id=18486124 https://news.ycombinator.com/item?id=18486124
- triceratops 6y agoI'm sorry to say this, but it's not a problem with the newfangled stuff. I think you just don't work with very good frontend devs. Which isn't surprising honestly - it has the lowest barrier for entry of any programming specialization (I started there myself).
- z3t4 6y agoI think its a problem with selling. People want to sell. So out with the old, in with the new. Lets revive some of the trends from the 70's. Or lets rewrite all this code to use classes. Sell more books and courses. Hate on all solutions that dont require out products. Are you still writing plain old JS? In order to be pro you need to use these frameworks... Its all marketing. Trying to argue is like standing on a train track and argue a train to stop. The train will just continue. And plenty of people wanting to be on the hype train. Second problem is that buyers are not result focused. Few companies understand that they pay for these cool frameworks every time a user visit their website. They pay with 15% less conversion, or lower user satisfaction.
- hombre_fatal 6y agoOr they have real value by helping developers deliver features that users love while contending with the inherent statefulness of clients.
- rasz 6y agoIf little can do a lot just imagine what I can do with few megabytes: Google Gmail/Youtube engineers
- gear54rus 6y agoProbably a good batch of spaghetti code if you think vanilla can be used for anything serious. Or rewrite react yourself as another commenter already did.
- hutzlibu 6y agoIt is an old meme, that every js-developer, who does not use an existing framework, ends up with his own framework. (also happened to me) Depending on the scope of the work, this is not allways a bad thing. I like my own framework. It does exactly what I want and I can tweak it to my needs anytime. But I work alone and don't have to share my code with different developers, otherwise there would be problems ...
- goatlover 6y agoYeah, the one complaint with frameworks is they never do exactly what you want, instead forcing you to do what generally works for everyone, which is usually good enough. But also can be frustrating. Which is probably why there are many frameworks.
- andrewstuart 6y agoI'm an experienced React developer. I wanted to try out writing a plain vanilla JavaScript application - I enjoy plain JavaScript, it feels close to the metal. It wasn't long before I was craving an application framework that allowed me to cleanly organise and structure my application instead of it rapidly becoming a spaghetti. I also craved the ability to write small simple functions for making components. And I wanted a sensible way to organise data flow through the application. And I really, really wanted to be able to write in a declarative programming style instead of imperative - this is something you don't come to appreciate fully until you've lived it. And I don't care what anyone else says - I love JSX - it's totally makes sense to me. So despite a solid effort to try to go to vanilla JavaScript I've decided that a really good JavaScript application framework - whatever one you like - is a good thing. I'll leave vanilla JavaScript to the birds.
- triceratops 6y agoPretty much this. I knew all of the things she wrote about but all I could think was "I can't imagine writing foo.classList.add and remove 100 times. That's going to create some major spaghetti code once that project grows beyond a couple of pages"
- deleted 6y ago[deleted]
- bigiain 6y agoThere;s some deep truth here, and I suspect it's about a fundamental difference between "writing a plain vanilla JavaScript application" and "I wanted to use the same HTML to generate both a PDF (with Prince) and to make an interactive version of the questions." Reimplementing gmail or slack in html/css/vanilla-javascript, without an "application frameowrk is no doubt an exercise in futility. At the same time, reaching for React/Fluttr/Angular/frontend-framework-de-jour when all you need is to show and hide divs and maybe do css or scroll animations between them is, in my mind, an equally bad decision. (I can totally see why the framework-de-jour option gets chosen so often though - because no matter how written-in-stone the original specs saying "There wil be no functinality required beyond showing/hiding divs and css animations between them" are, we've all seen projects where a last minute critical/showstopper requirement for the web page to include something insane like a fully functional email client gets dropped in the FE dev's lap the Friday afternoon before launch Monday. Sure, the FE dev made the choice to use React, and while some (perhaps a lot?) of that is "resume driven development", at least some of the blame is on bad sales people and project managers as well...)
- jjcm 6y agoNice work! The only advice I’d give is don’t use patterns like div.parentElement.parentElement.foo() It’s inflexible and will break if you ever make dom changes. Use the .closest() selector instead. It’s like a reverse .querySelector (.closest selects ancestors, .querySelector selects descendents) which means you’ll have more specific code.
- soylentgraham 6y agoTIL about .closest! From the article.
- bbx 6y agoOf course you can do quite a bit with JS. Some of the projects I’ve made You can swap CSS classes in JS. But how do you know which classes are available? You can target HTML elements in JS. But how do you know which elements are available? You can set “.innerHTML”. But how do you save the state of the application? As soon as the app grows a little bit in complexity, you’ll end up building functions to keep track of things and functions to perform repeated actions. You end up building a tiny framework that only you know how to use. When it’s time to debug and grow, you’ll need a proper JS framework anyway. The thing I would say about popular JS frameworks, and which I’m surprised about, is how they favour single page app structures rather than “drop-ins” to enhance a page. I’ve yet to see React or Angular be used as part of a page, which is crazy because they would enhance the developer experience so much, without disturbing the classic way of delivering pages server-side with classic routing and classic user experience.
- orange8 6y ago> You can swap CSS classes in JS. But how do you know which classes are available? > You can target HTML elements in JS. But how do you know which elements are available? This assumes someone else is creating the CSS and HTML for you? Have rules or coding and naming conventions like BEM for example. That's what a framework basically is, a set of rules and conventions about how to structure an App. What you need is proper architecture, regardless of whether or not it is based on a popular framework. That's how the popular frameworks started out to begin with.
- ehnto 6y agoThere are other frameworks that do favour a "drop in" style of development, with native Web Components being one of them. I used Riot for this for a while, and tried native Web Components as well. My current approach for zero dependency/build, one off UI components is: <div class="some-component" data-props="{}"> ...more HTML... <button class="some-component__button">Click Me</button> <script type=text/javascript"> (function() { var component = document.currentScript.parentNode; var props = component.dataset.props; var button = component.querySelector('.some-component__button'); button.addEventListener('click', function(){ ...doStuff... }); })(); </script> </div> If it needs a global state, or is part of a larger more dynamic UI I'll start looking at a framework. But for an otherwise static website, it's so much easier to do it that way than it is to introduce an entire framework and build pipeline in order to do a handful of JS components. It's also a somewhat defensive approach, useful in legacy applications with lots of hodge podge JS going on. Generally speaking, you don't cause any problems, and don't encounter any conflicts. I used to have a class based/web components way to do this, but I don't even bother with that anymore. You don't gain anything from introducing complexity in this circumstance.
- yesenadam 6y agoWhen starting to learn/write JS, I found a few of these basic name-shortening functions from HN's own JS very useful, and well-named: function $(id) { return document.getElementById(id); } function byClass (el, cl) { return el ? el.getElementsByClassName(cl) : [] } function byTag (el, tg) { return el ? el.getElementsByTagName(tg) : [] } function allof (cl) { return byClass(document, cl) } function hasClass (el, cl) { var a = el.className.split(' '); return afind(cl, a) } function addClass (el, cl) { if (el) { var a = el.className.split(' '); if (!afind(cl, a)) { a.unshift(cl); el.className = a.join(' ')}} } function remClass (el, cl) { if (el) { var a = el.className.split(' '); arem(a, cl); el.className = a.join(' ') } } function html (el) { return el ? el.innerHTML : null; } function attr (el, name) { return el.getAttribute(name) } function tonum (x) { var n = parseFloat(x); return isNaN(n) ? null : n } function remEl (el) { el.parentNode.removeChild(el) } function posf (f, a) { for (var i=0; i < a.length; i++) { if (f(a[i])) return i; } return -1; } function apos (x, a) { return (typeof x == 'function') ? posf(x,a) : Array.prototype.indexOf.call(a,x) } function afind (x, a) { var i = apos(x, a); return (i >= 0) ? a[i] : null; } function acut (a, m, n) { return Array.prototype.slice.call(a, m, n) } function aeach (fn, a) { return Array.prototype.forEach.call(a, fn) } function arem (a, x) { var i = apos(x, a); if (i >= 0) { a.splice(i, 1); } return a; } function alast (a) { return a[a.length - 1] } function vis(el, on) { if (el) { (on ? remClass : addClass)(el, 'nosee') } } function noshow (el) { addClass(el, 'noshow') } function elShow (el) { remClass(el, 'noshow') } function ind (el) { return (byTag(el, 'img')[0] || {}).width } https://news.ycombinator.com/hn.js https://news.ycombinator.com/hn.js
- ehnto 6y agoThe class related functions have been made native by the classList property of elements. element.classList.has('someClass') //true if present element.classList.add('someClass') //add to element element.classList.remove('someClass') //remove from element element.classList.toggle('someClass') //remove if present, add if not present I would also argue element.querySelector and element.querySelectorAll are plenty shorthand to replace the selector helpers! Not saying HN should rewrite their JS obviously, just for anyone reading this and wondering if there are native equivalents.
- _pdp_ 6y agoA little bit of C can do a lot, yet most 3A games are written with frameworks.
- ben-schaaf 6y agoIf all you need to do is display a native dialog, read some files, etc. you're better off without the massive 300MB game engine. A lot of people making native apps aren't game devs and a lot that are aren't making tripple-A games. In the same way there's definitely web apps that are better off with a large framework, but if all you're doing is toggling some classes you're better off without them. Most websites don't need to be SPAs.
- afarrell 6y agoWhat sort of automated test framework do folks use while writing vanilla JS?
- wolfgang42 6y agoIf I need tests I usually reach for the same tools I’d use for testing any other JS—in my case mocha, chai, and nyc—plus jsdom and jsdom-global (so I don’t have to spin up a browser for unit tests) and chai-dom.
- runarberg 6y agoI use AVA[1] and c8[2] for coverage. It only works in node so I have to use JSDOM to mimic the browser environment. 1: https://github.com/avajs/ava https://github.com/avajs/ava 2: https://github.com/bcoe/c8 https://github.com/bcoe/c8
- anonytrary 6y agoHere's what a "little bit" of JavaScript can't do: 1. Manage subtle browser differences 2. Store and manage reactive state 3. Manage declarative updates You can build a simplified version of React in under 100 lines of code, but that probably won't take care of subtle browser differences. A little bit of JavaScript can do a lot, but it can't do everything you need these days.
- andai 6y agoDoes anyone know a 100 line react clone or tutorial? That sounds very educational.
- Tenemo 6y agoThis one is amazing: https://pomb.us/build-your-own-react/ https://pomb.us/build-your-own-react/
- woutr_be 6y agoI don’t think the author is arguing that you have to replace your React applications with vanilla JS, but instead of using React by default, you could consider using vanilla JS. The tree things you mentioned might be important to you for a specific project, but these are not requirements for every project. So instead, do what makes sense to you. And remember that you don’t always need a framework to achieve what you actually need.
- z3t4 6y agoNever set .innerHTML ! document.createElement is very tedious. But you can hide them inside pure functions that returns your component. You could for example put the confetti button example into a function and whenever you want a confetti buttton const button = confettiButton("hurray"); body.appendChild(button); Or you could make a class and extend the Button into a confetti button. You can then use innerText to change values. And use other DOM methods instead of redoing the innetHTML. When using function abstractions the DOM updates can be private, and you don't have to worry about innerHTML elsewhere overwriting your changes. Basically React was invented to overcome spaghetti innerHTML, but you can solve the problem with vanilla JS too, just stop thinking about the DOM as HTML, think of it as a tree.
- irrational 6y agoI’ve been doing web development for more than 23 years. I’ve pretty much stuck to vanilla JS that entire time (though I did use jquery during the worse of the browser incompatibility years). I keep meaning to learn some of the newer libraries but never get around to it since vanilla JS does everything I want it to do and I already know it. I wonder if I would be as surprised by what libraries like Vue can do as this person is about vanilla JS.
- onion2k 6y agoNot a Vue example but have a look at https://github.com/drcmda/reactanoid https://github.com/drcmda/reactanoid It's an Arkanoid clone (bat and ball game) written in React, with react-three-fibre for WebGL, zustand for state management, and use-cannon for physics. The full version is about 250 lines and there's also a simplified version that weighs in at 60 lines (not including the library code obviously). It runs at a solid 60FPS on a very basic laptop. Doing the same thing in vanilla JS, using the same libraries (or alternatives) would be a lot more work, and would end up with the exact same result. That's the point with a well written framework-driven app - when you use something like React or Vue you should be aiming to get the same end result as a vanilla JS app, but with much less effort. The cost to the user should really only be a slightly bigger download.
- qubyte 6y agoI enjoyed this. It conveyed a little of the sense of wonder that can come with just a touch of JS without bashing the frameworks. I also liked the emphasis on making HTML and CSS do the heavy lifting by adding and removing CSS classes as triggers.
- 0xy 6y agoThis is great. In legacy codebases for my employer I'll always reach for vanilla JS when solving a problem or implementing a new feature. Better than tacking something on in jQuery.
- Nikaoto 6y agoIt's as if using the technology the way it's designed to be used is a reasonable idea. Who could've thought?
- feiss 6y agoIn 2020, with our mature and cross browser compatible JavaScript, it surprises me that many people are still discovering vanilla JavaScript. Is something wrong here?
- djKianoosh 6y agoI get the sense that there are a ton more beginner tutorials based on frameworks. And those type of tutorials are underrated ways that lots of people use to learn "js".
- elisee 6y agoIndeed! I swore off Web development a couple times because of the mess but now my whole party games platform is made with plain JS, no bundling, no post-processing, no big frameworks and it's pretty good. (Although I did recently augment it with some JSDoc types, for long-term maintainability) At least three devs have asked why I wasn't using some reactive framework or big library. I know why: I'm much more productive without! Simple DOM helpers go a long way: https://jklm.fun/common/dom.js https://jklm.fun/common/dom.js (If you're curious: https://jklm.fun https://jklm.fun)
- runawaybottle 6y agoWell isn’t that the economics of it? A new dev is much more productive in the new thing they learned. A more seasoned dev is more productive in all the things they already know. The question is, who gets to dictate the economics here? The answer is always Thanos, balance. In a true meritocracy this is a legitimate fight, neither side has a one up. We have to find the pros and cons of the old and new and iterate.
- afkqs 6y agoAfter a full year of only working with React, I started working on a few projects a couple of days ago with Vanilla JS only and it is refreshing. It feels like writing Haiku poems.
- tekstar 6y agoI think if you make websites at any layer you owe it to yourself to learn fundamental CSS and modern JavaScript (ES6).
- fefe23 6y agoThank you for this. Really. Thank you. I wish we had more postings like this. No complaining, no whining, no "my framework is better than your framework". Just what problems you had and how you solved them. This actually gives me something to take away.
- jb3689 6y agoUnfortunately the reason we have frameworks is because there are so many gotchas. It's true - vanilla JS can do a lot however, there are also a lot of strange edge cases that aren't handled well. If you don't mind failing on these cases then it is fine, but this is why things like jQuery were built and why your React project has hundreds of dependencies. Personally I prefer vanilla JS, but for any serious project it is hard to choose it
- patrec 6y agoDoes anyone have a nice list of interesting, compact examples of sites or apps that are written in vanilla javascript?