Earlier quoted context omitted.
If you don't already know what CORS is, you're probably not a Web developer and don't need to know.
To be fair, there are many web devs who have never needed to worry about cross origin resource sharing
How to win at CORS
21–30 of 128 posts
Re: How to win at CORS
#22Earlier quoted context omitted.
For me, adding the ending slash is just like adding semicolons at the end of javascript statements. They may be optional sometimes, but there is something to be said about consistency and clarity that comes with using them always. Less cognitive overload to boot.
Although there are certainly some similarities, trailing slash on empty tags is a different case to automatic semicolon insertion. Semicolons are mostly optional, but the trailing slash is never required, and does absolutely nothing—most specifically, it doesn’t close tags, and that’s what I’m getting at with my position of the trailing slash being mildly harmful: it’s teaching a mental model that’s simply wrong.
Re: How to win at CORS
#23Earlier quoted context omitted.
Although there are certainly some similarities, trailing slash on empty tags is a different case to automatic semicolon insertion. Semicolons are mostly optional, but the trailing slash is never required, and does absolutely nothing—most specifically, it doesn’t close tags, and that’s what I’m getting at with my position of the trailing slash being mildly harmful: it’s teaching a mental model that’s simply wrong.
The name is literally a "self-closing tag", isn't it? And it's better for someone else reading: you may not recall what the tag is, but you know you don't have to look for a closing tag below.
Re: How to win at CORS
#24There are many ways to lose at CORS and this one is my story.
Re: How to win at CORS
#25Earlier quoted context omitted.
If you don't already know what CORS is, you're probably not a Web developer and don't need to know.
To be fair, there are many web devs who have never needed to worry about cross origin resource sharing
https://addons.mozilla.org/en-US/firefox/addon/access-contro...
because properly configuring the backend is ¨too complicated¨.
Been there, done that.
Re: How to win at CORS
#26Earlier quoted context omitted.
Author here! I used to have strong feelings about formatting stuff like this, but I since realised there are better things to spend effort on. For formatting, I just let https://prettier.io/ do it's thing, and it added the />. Although I do configure it to use single quotes in JS, so I guess I still have some opinion there. In terms of HTML, how far does your "but it isn't necessary" opinion go? Lots of closing eleme…
Well, for my own personal stuff I omit just about all that I can—head/body start and end tags, html end tag (not start tag because it has at least a lang attribute), tbody start tag where possible, thead/tbody/tfoot/tr/th/td/li/dt/dd/p end tags almost all of the time, attribute value quotes where valid… mostly just because it’s fun doing so, and in some cases because it makes things decidedly cleaner (especially tabl…
Yeah, I don't always agree with Prettier, but ugh, I wasted hours in my early career arguing about formatting with teammates, but now I just let Prettier do it's thing, get over it, and spend the time on something else.
Re: How to win at CORS
#27I can tell you how to lose at CORS in Chrome. If your browser caches a response, and sometime later you mutate the request by adding the "Origin" header it (e.g, add attribute crossorigin="anonymous" to a tag), Chrome won't make a new request. What it will do is use the cached response, which is missing the ACAO response header, and thus the browser rejects a file from its own cache via draconian security policy. The…
Getting Vary right isn't just important for Chrome, it's important for CDNs too.
Re: How to win at CORS
#28I can tell you how to lose at CORS in Chrome. If your browser caches a response, and sometime later you mutate the request by adding the "Origin" header it (e.g, add attribute crossorigin="anonymous" to a tag), Chrome won't make a new request. What it will do is use the cached response, which is missing the ACAO response header, and thus the browser rejects a file from its own cache via draconian security policy. The…
Author here! The post covers this detail. This happens because your response is missing a Vary header. Getting Vary right isn't just important for Chrome, it's important for CDNs too.
Re: How to win at CORS
#29Earlier quoted context omitted.
To be fair, there are many web devs who have never needed to worry about cross origin resource sharing
How do you become one of those kind instead of smashing your face against CORS constantly