I've been delving into some specs of HTTP and HTML lately, and one thing I've noticed that always irked me is that, you can use GET and POST as methods for form submission, but not the other ones like PUT, DELETE, and PATCH. All three of these methods have been available since like the 90s or early 2000s (with the last one PATCH just being standardized relatively recently compared to the first two), when it was clear that HTTP is not just a query protocol like Gopher was but also can be full-on CRUD.
You can definitely do those three methods in the browser today, but that requires something like XMLHttpRequest which means you need JavaScript just to use those methods. And even if one doesn't mind that requirement, XHR is just too clunky imo.
Which begs the question: why can't we use those three in a form like we can with GET and POST? Why can robots, scripts, and web apps using a website's specific REST API (which has those methods) easily use them but we human users can't? It just doesn't make sense. Imagine if instead of having to create a specific "/delete" resource that humans POST to (which is just semantically so wrong), people can just DELETE a relative url. Or instead of "/edit", we PUT to the existing resource. Leaving POST mostly being its intended purpose: to create resources!
What's interesting is that PUT and DELETE (PATCH wasn't considered for some reason even though it got standardized the same year as HTML5 was still being developed, probably because people weren't really sure yet how to implement a PATCH for a form) almost got into the HTML5 spec, as evidenced by this W3C bugzilla report. However, somebody noticed that the way to access those methods didn't make sense semantically. Which I guess is fair, if we got an alternative that would make sense semantically. But we never got one, and this became a case of "perfect being the enemy of good". And tbh I am surprised WHATWG later on didn't make a positive difference here by just implementing PUT & DELETE in a form and calling it a day, since there was plenty of web developer support in making those methods available without JS...
Mozilla also got these methods implemented in bug 583288 which was supposed to be slated for Firefox 4.0, before it got removed in bug 600813. And I think the Mozilla implementation in the former bug is pretty trivial that it can be used almost verbatim in our codebase.
So, what do we think of all of this? We already have stuff that isn't in the spec (or rather, no longer in the spec) like <style scoped>, and I'd imagine if webdevs today know about this issue we could have the same levels of support for scoped styles and can therefore justify extending HTML on our own.
HTTP PUT, DELETE, and PATCH without JavaScript?
Moderators: trava90, athenian200
-
- Keeps coming back
- Posts: 953
- Joined: 2020-11-03, 06:47
- Location: Philippines
HTTP PUT, DELETE, and PATCH without JavaScript?

"Destroying things, smartly!" - IJN Samidare, probably
Avatar artwork by ebifurya: https://www.pixiv.net/artworks/85379109
XUL add-ons developer. You can find a list of add-ons I manage at http://rw.rs/~job/software.html.