I like the MDN for quick reference but the actual HTML spec is actually quite well written and has lots of useful examples [2].
A product is poorly-advertised indeed, but which product?
As an example, on their site, they’re sending about 68/12KB gzipped of styles. Some are already unused and could be removed by straightforward dead code removal. Inlining variables that are set only once and removing their definitions (which incidentally encompasses that dead code removal) reduces it to 40/8KB which will both transfer and evaluate faster. (A further 20% of the styles are also unused and possibly sanely removable.)
The hate for JS frameworks is usually warranted, in this case I think nuance is missing. It's also not as black and white as people paint it to be, IMO.
But there is quite some projects where you don't even need that.
Learning HTML/CSS/JS is a good idea as ultimately any framework or serverside code will interact with some combination of the three. Having a strong grasp of how HTML/CSS/JS work is the perfect foundation for learning something that runs serverside. And you get there by building projects that predominantly lean on the three. Whether they are private or professional, who cares as long as they are cool and someone learns something from it?
For example angular hello worls is super duper simple. But then business apps become a giant pile of crap, the eprformance goes to shit and sometimes stuff that should work stops working. The issue is the magic, if use a sane library you can just run the code in debugger step by step and see what happens but with magic stuff you get a giant call stack with garbage that is impoosible to understand.
So when I can I rip out magic and replace it with function calls , getters and setters. Maybe is my bad luck that I always have to work on prtojects created by others and all the time this others did it wrong. Nobody can convince me that angularjs1 is a framework designed by competent people with experience in GUIs, maybe the newer version are better if those buys learned on the job what they should have known from the beginning.
I guess once you get into all the hooks and contexts and fancier stuff things might start to be a bit magical. But I like it a lot better than Angular, which I agree is very much overly magicked.
It's almost never warranted.
> In 2008 Crockford published a book announcing his discovery that Javascript, contrary to prevailing opinion, has good parts. He describes this as "heresy", and as "possibly the first important discovery of the 21st century", noting that it came as a "great surprise to the community of javascript developers, and to the world at large." He attributes the discovery to his having read the ECMAScript Standard, which he says "literally changed my life." He also notes that the specification document is of "extremely poor quality", "hard to read", "hard to understand", and says that the ECMA and the TC39 committee "should be deeply embarrassed".
I own that book and I still hate Javascript (it's not the fault of the book). Is there another language with such a book?
[1] https://en.wikipedia.org/wiki/Douglas_crockford#Opinions_on_...
Perl maybe, if you end up having to re-read some.
There are many languages that I do not like, but I hate none, so I am curious for the reasons of that strong feeling?
The language is very permissive, making it not only easy to shoot yourself in the foot, but in the head as well. There is no easy way to say that your code is semantically correct because JS will allow it to digest anything. So, unless you do thorough review, bad code can easily get through.
Dependency hell if you're using NPM.
I'd be happy if the community was focusing on implementing some kind of default set of libraries, instead of adding syntactic sugar now and then on top of JS. I remember switching from Java to Kotlin, and the collection API was a real pleasure to work with. But in JS, everyone wants to use their set of libraries. Creating a starter project will get you hundreds of dependencies that you can never vet.
"The language is very permissive, making it not only easy to shoot yourself in the foot, but in the head as well. "
But I am actually not aware of much footguns of the language itself.
That is, if you stick with "the good parts" (even though I share not all the views from the book).
" Creating a starter project will get you hundreds of dependencies that you can never vet."
And it is possible to write clean vanilla js, or stick to limited frameworks. You have to maintain strict discipline though. And nowdays I would use typescript for a new project.
…and then I'll have no reason to dislike this language. Got it. Am I allowed to dislike the newish template literal syntax too?
But you said "hate" before, which is a bit stronger than not liking.
The only time I came close to hating a language, was when I was forced to overtake someones half assed php project.
And I still do not like the syntax and have never touched any php code ever since, but I still do not hate the language, or its designers or users. I just avoided it. But hate has the vibe of wanting to destroy something ..
And well, yes, a nice clean start of the web would not be such a bad thing - if there would be some language or plattform everyone can agree on. Which is likely not happen and will just recreate the mess we have already.
> hate has the vibe of wanting to destroy something
You may be right, and given half a chance…
The hate for large frameworks is warranted by their poor performance and bloat while struggling to achieve simple objectives in the most challenging ways.
article a :has_("click here ")
to select elements that are otherwise hard or impossible to target. Of course, I don't want to use it on the websites - I want it for userstyles, so I can swiftly and efficiently deal with the insanely bad UX of most of webpages, despite their authors making it hard to fix (often on purpose).That, and I'd like some way to punch through shadow DOM, because as far as I can tell, elements in the shadow DOM cannot be addressed by userstyles at all, which prevents me from fixing annoyances in some webapps (looking at you, Gerrit).
news.ycombinator.com##a:has-text(Hacker News):style(color: green !important)
[1]: https://github.com/gorhill/uBlock/wiki/Procedural-cosmetic-f...
[2]: https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#... //article//a[contains(., "click here ")]
The equivalent to document.querySelector in JavaScript: document.evaluate(
'//article//a[contains(., "click here ")]',
document,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null,
).singleNodeValue
And the document.querySelectorAll (which returns a static node list) equivalent would use ORDERED_NODE_SNAPSHOT_TYPE, with .snapshotLength and .snapshotItem(index) on the result object. Yes, this API is written in a very old style, and could do with being wrapped in a more pleasant API.See https://www.w3.org/TR/1999/REC-xpath-19991116/ for the syntax, and https://developer.mozilla.org/en-US/docs/Web/API/Document/ev... for document.evaluate(). You will sadly not find a great deal of other useful documentation.
As for shadow DOM: yeah, you can’t target closed shadow DOMs at all in any way, by design. Fortunately most are open so that it is at least possible to get into them, even if it’s a pain since the normal tools can’t pierce the boundary.
—⁂—
¹ If you wanted to only match “click here ” in an immediate child text node of the <a> element, these four work and are equivalent:
//article//a[./text()[contains(., "click here ")]]
//article//a[text()[contains(., "click here ")]]
//article//a[contains(./text(), "click here ")]
//article//a[contains(text(), "click here ")]
These will be more efficient than the first-used selector. Where CSS is mostly unaffected by selector complexity because it largely evaluates from right to left, XPath is more likely to be doing full traversals, which will benefit from more specific selectors, hence things like prefixing paths with /html/body, or only evaluating in document.body, in order to skip traversing the head altogether, if that will never match; and you can easily imagine that contains(//a/text(), "…"), which selects text nodes that are children of <a> elements and thus has selected nodes that have a trivial string-value, will be faster than contains(//a, "…"), which will need to stringify every <a> element, entailing further traversal and string construction. Mind you, the differences in all this will mostly be very small in practical terms.It's pretty amazing, HNers' capacity to read a request that includes a clear, concise (and satisfiable) requirement—no frameworks—and then dozens of respondents write up answers predicated on the use of this or that framework, thus contradicting the entire premise for the question.
I did miss SCSS though.
Using modern HTML and CSS will get you pretty far these days.
For example, dealing with forms used to be problematic in a few different ways without JavaScript or something server-side.
Now form validation can be done with CSS [1].
For example, static site hosts like Netlify have services for dealing with the form data [2]. 100 free form submissions per month.
I agree that tooling is out of control. Jekyll [3] is great for getting started with building static sites. When using Jekyll, my build tool of choice is a Makefile [4].
[1]: https://webkit.org/blog/13096/css-has-pseudo-class/#styling-...
[2]: https://www.netlify.com/products/forms/
[3]: https://jekyllrb.com/
[4]: https://blog.mads-hartmann.com/2016/08/20/make.html