Live data from Hacker News

Why does target="_blank" have an underscore in front? (2024)

kyrylo.org

161–170 of 203 posts

Re: Why does target="_blank" have an underscore in front? (2024)

#161

Earlier quoted context omitted.

As another borrowed convention, JS developers of yore (and likely some today still) used an _ prefix to denote “private” function/methods. Quotes as it’s just a convention - today JS supports # for actual private members in class syntax.

I use underscore to prevent shadowing of variables names. Not sure where I picked up that habit though.

I've seen that before.

A related conventional use of underscores in JS variable names is when "discarding" values in positional settings, like destructuring arrays.

E.g. `const [_, a, b] = triple`

In general, underscores in JS seem to be used to help call out what to ignore or what is less important.

Re: Why does target="_blank" have an underscore in front? (2024)

#162

Earlier quoted context omitted.

I use underscore to prevent shadowing of variables names. Not sure where I picked up that habit though.

I've seen that before. A related conventional use of underscores in JS variable names is when "discarding" values in positional settings, like destructuring arrays. E.g. `const [_, a, b] = triple` In general, underscores in JS seem to be used to help call out what to ignore or what is less important.

You've been able to `const [, a, b] = tuple;` for a wee while now FYI.

But yeah for every other time most linters will accept _ as "ignore this".

Re: Why does target="_blank" have an underscore in front? (2024)

#163

I went digging in W3C archives to find relevant discussions. There are 4 reserved target names: _blank, _parent, _self, _top. - 1995 Sept https://web.archive.org/web/19990202141025/http://home.mcom.... Netscape Navigator 2.0a2 release notes including rollout of TARGET. - 1995 Sept https://lists.w3.org/Archives/Public/www-html/1995Sep/0034.h... First definition of them; spec text provided by "the Netscape Navigator ma…

There probably was no discussion about it. Back then you didn't have tens of managers looking to add their input to a project, so if you came up with something, you could just demo it, and unless someone had a very specific reason to reject it, nobody would.

I'm not saying this is the answer, but it very well could be that whoever wrote the function that handles this decided on an underscore and nobody ever even questioned it.

Re: Why does target="_blank" have an underscore in front? (2024)

#164
post #88
post #18

I was expecting this post to explain why it's an underscore specifically, as opposed to a dollar sign, an asterisk, a caret, a tilde or some other special character. I can only assume it's a holdover of languages like C where the standard library has some reserved names that start with an underscore. https://devblogs.microsoft.com/oldnewthing/20230109-00/?p=10...

I wouldn’t say it’s a “holdover”, it continues to be a common convention for marking internal or reserved use.

I do it every day, so I see it from your perspective.

I'm willing to bet there are kids who do not though. Given how many crazy colours my IDE shows everything in, I could definitely believe there are people that go, 'Why bother, aren't those private members blue anyway?', or some such similar train of thought.

Of course if your IDE is little more than notepad, then such things are still important. For me, that's the Arduino IDE. I have to admit I really like writing micro controller code in it, it's a bit like writing code 30 years ago (both the good and bad parts).

Re: Why does target="_blank" have an underscore in front? (2024)

#165
post #155

Earlier quoted context omitted.

If front-end devs would stop reinventing things using JS that can be done in CSS, I'd be so happy.

Why?

Not the GP, but my two cents: because JS sucks and CSS can already do it.

Re: Why does target="_blank" have an underscore in front? (2024)

#166

Earlier quoted context omitted.

I've seen that before. A related conventional use of underscores in JS variable names is when "discarding" values in positional settings, like destructuring arrays. E.g. `const [_, a, b] = triple` In general, underscores in JS seem to be used to help call out what to ignore or what is less important.

You've been able to `const [, a, b] = tuple;` for a wee while now FYI. But yeah for every other time most linters will accept _ as "ignore this".

I had no idea that was a thing!

Thanks for teaching me something today.

Re: Why does target="_blank" have an underscore in front? (2024)

#167

Tangential, but I would really like frames to come back for incremental document updates, like LiveView/Hotwire/HTMX. You can just start working like that today with one of those libraries, but it would be so neat to have a common standard for describing an update to a targeted frame.

Alex and (to a much lesser extent) I are trying to get a modernized version into the HTML spec:

https://github.com/alexpetros/triptych

Re: Why does target="_blank" have an underscore in front? (2024)

#168

Earlier quoted context omitted.

I've seen that before. A related conventional use of underscores in JS variable names is when "discarding" values in positional settings, like destructuring arrays. E.g. `const [_, a, b] = triple` In general, underscores in JS seem to be used to help call out what to ignore or what is less important.

You've been able to `const [, a, b] = tuple;` for a wee while now FYI. But yeah for every other time most linters will accept _ as "ignore this".

Oh yeah, I always forget about that.

Re: Why does target="_blank" have an underscore in front? (2024)

#170

Why did we move away from this model of web development? If I remember back that far, it seems like fairly soon after this was when the meta starting telling us that frames were bad, and using was bad, etc. It all honestly seemed a lot easier than what has come after.

Framesets were a bad idea because they didn’t work well with links, bookmarks, and search engines. Tables are fine when used correctly though.
Post reply on HN