Live data from Hacker News

CSS is powerful, you can do a lot of things without JS

github.com

281–290 of 319 posts

Re: CSS is powerful, you can do a lot of things without JS

#281
post #122

I've worked with people who did things like this. It's not fun for anyone else on the team to try and figure out why you're using specific pseudo selectors on tags in a child inside a sibling in some label to make an accordion that would take 3 lines in Javascript.

Using HTML5 tags such as , you don't need CSS or JS! Try this in Chrome: https://jsfiddle.net/timdavila/f5rcarmn/

So I didn't try it in Chrome, and it doesn't work in Firefox, yet. But I can see where this is going and it would be awesome if it actually worked.

Re: CSS is powerful, you can do a lot of things without JS

#282

Earlier quoted context omitted.

If it involves jQuery then it is not 3 lines. The original claim was 3 lines of Javascript. Making a claim something is only 3 lines of Javascript without including the fact that jQuery is required is a disservice to the many people that made jQuery the wonderful library that it is. That is the source of my disagreement.

You're being disingenuous. Firstly, "3 lines of Javascript" wasn't meant to be taken literally. Not only that but 73% of the top 100,000 websites use jQuery - if you are on a large web development project you are more likely than not using jQuery. [1] http://trends.builtwith.com/javascript/jQuery

Since two others have completed the task with literally "3 lines of Javascript" then I'm not being disingenuous at all. I requested the 3 lines was given roughly the same example by two different people.

And I know the trends around jQuery, that was not the issue at all.

Re: CSS is powerful, you can do a lot of things without JS

#283

Earlier quoted context omitted.

If it involves jQuery then it is not 3 lines. The original claim was 3 lines of Javascript. Making a claim something is only 3 lines of Javascript without including the fact that jQuery is required is a disservice to the many people that made jQuery the wonderful library that it is. That is the source of my disagreement.

That isn't a disservice to jquery. The fact that people don't explicitly mention it could actually be viewed as a demonstration of its ubiquity.

No, it's people becoming not being able to know the difference between jQuery and Javascript. Calling either of them the other is a disservice to both.

Re: CSS is powerful, you can do a lot of things without JS

#284

Earlier quoted context omitted.

If it involves jQuery then it is not 3 lines. The original claim was 3 lines of Javascript. Making a claim something is only 3 lines of Javascript without including the fact that jQuery is required is a disservice to the many people that made jQuery the wonderful library that it is. That is the source of my disagreement.

>>If it involves jQuery then it is not 3 lines. The original claim was 3 lines of Javascript. jQuery is JavaScript, so...

As pointed out, yes it is indeed Javascript. If you make use of it then you cannot claim your code is shorter in lines by choosing to not include the jQuery code.

I've written a couple of small jQuery plugins and I don't claim I wrote this awesome Javascript code that does this cool thing. I say I made a jQuery plugin that does this cool thing.

Re: CSS is powerful, you can do a lot of things without JS

#285
post #212

Earlier quoted context omitted.

If you had read the next sentence of my comments you would have seen that it would be a "few more lines" if you didn't use jQuery, basically you need a function like: function eachItem(arrayLike, cb) { return [].slice.call(arrayLike).forEach(cb); } So 3 more lines. If I said you can write a very verbose accordion in under 20 lines would that be good enough for you?

>> So 3 more lines. If I said you can write a very verbose accordion in under 20 lines would that be good enough for you? Since that's more realistic, yes that would do nicely.

Crap, can't edit.

Two others completed the accordion in 3 lines task without jQuery.

Re: CSS is powerful, you can do a lot of things without JS

#286
post #271

Earlier quoted context omitted.

Your complaint is essentially that they are using a language that other people working on the same project don't know. There are good reasons to discourage that: it fosters bikeshedding, and CSS's ways of expressing dynamic behavior doesn't match intuition as well as procedural javascript. However these reasons have to be weighed against technical limitations. Using CSS for dynamic behavior is often better than using…

Lets be honest, 99% of people who disable javascript are programmers who take great honor in complaining about every website that is more than 200k in size. This is a non-issue for most companies.

If we're being honest, then no.

Re: CSS is powerful, you can do a lot of things without JS

#287
post #271

Earlier quoted context omitted.

Your complaint is essentially that they are using a language that other people working on the same project don't know. There are good reasons to discourage that: it fosters bikeshedding, and CSS's ways of expressing dynamic behavior doesn't match intuition as well as procedural javascript. However these reasons have to be weighed against technical limitations. Using CSS for dynamic behavior is often better than using…

Lets be honest, 99% of people who disable javascript are programmers who take great honor in complaining about every website that is more than 200k in size. This is a non-issue for most companies.

You're getting the wrong impression of those who disable javascript. Yes, they tend to be programmers, or otherwise tech-minded, because they have to know what javascript is, know how to disable it, and (most limitingly) understand the reasons for doing so. And naturally, if you disable javascript, you're going to be annoyed when sites don't work, going to consider the trend of requiring javascript regressive, and going to publically complain in the interest of promoting the health of your own profession. Notice that "taking great honor in complaining" is not the underlying cause of disabling javascript but rather an effect. The actual motivations vary.

Re: CSS is powerful, you can do a lot of things without JS

#288

Earlier quoted context omitted.

That isn't a disservice to jquery. The fact that people don't explicitly mention it could actually be viewed as a demonstration of its ubiquity.

No, it's people becoming not being able to know the difference between jQuery and Javascript. Calling either of them the other is a disservice to both.

I'm old. I wrote many, many, many lines of JavaScript before jQuery ever existed, I know the difference very well. Nobody is confused.

Ignoring the fact that it clearly wasn't intended to be taken literally, "in 3 lines of JS" when speaking in the context of a team effort on a web application can be understood as "adding 3 additional lines to the source code." Context.

There's no need to be nasty and argumentative for no reason.

Re: CSS is powerful, you can do a lot of things without JS

#290

Earlier quoted context omitted.

It would actually be wise to arm special forces with laptops, as we're only going to see more and more operations depending on hacking into security systems and building automation systems with the rise of smart devices that have no business being on the web (aka IoT). Only a matter of time before guns will only really be useful in third world countries without electricity.

So, are you saying that a bunch of guys with wire cutters and guns would be unstoppable? Simple scenario: 1. Cut all the power (grid connections A, B and C, disable generators) - nobody says no if you ask nicely and have a big gun 2. Watch the special teams struggle helplessly to hack into offline systems 3.PROFIT!!! Your assumption (that the network somehow runs on unicorn farts and that the need for boots-on-the-gr…

Not good at metaphorical sarcasm, eh? Special forces not using guns because they sometimes need hackers make as much sense as web developers not using CSS because they sometimes need Javascript-based layout.
Post reply on HN