Live data from Hacker News

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

github.com

131–140 of 319 posts

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

#131
post #97
post #82

Earlier quoted context omitted.

You are missing semicolons in there.

My sentence is fine according to Grammarly, LanguageTool, and Word. So, can you be more specific, please? Anyway, I was talking about basic rules that even idiots should get right.

> I was talking about basic rules that even idiots should get right.

Ah, like politeness?

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

#133
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.

Shouldn't pure CSS animations have better performance?

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

#134

Earlier quoted context omitted.

CSS ( properly written ) is easier to debug than JS.

Easier to find the bug harder to fix I think. The problem is CSS has a global scope - you change one thing and breaks the whole site's layout. With javascript usually code affects more specific areas of the site/web app.

> The problem is CSS has a global scope - you change one thing and breaks the whole site's layout.

I know what you mean (I tried fighting the default Plone theme before the littering of various instances of !important got refactored out) - but it's also deeply ironic. It's Cascading Style Sheets - if you don't use the namespacing - you will have a bad day. Remember how bad javascript snippets based off of tweaked code that some old version of Dreaweaver had injected to a project some generations prior to the one you were working on was?

Just as people "programmed" javascript without learning the language, so people did with CSS. And not just "hammer it with !important until it stops resisting" either.

Simple example: today, if you want poor man's stand-alone component ; stick the html in a div (or other element) with a class of Mygreatcomponent, and style from there with direct parent/child-stuff. Sure, you need to do manual namespacing, but even if your project is huge, you can grep for class='whyisitallpinkComponent'.

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

#135
post #102

Earlier quoted context omitted.

There is an :empty state you can use. I'm not looking at the demo right now but I've added messages like this: .container:empty:before { content: 'There are no Messages' }

Just be aware that the element really has to be empty - any whitespace (including empty child tags etc.) makes the selector ignore it.

Yeah, whitespace makes a textNode so an element containing any nodes can't be :empty. Also gotta watch out for those whitespace-only extra nodes when counting the children of an element with JavaScript, it often returns more children than you think at first ;)

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

#136
post #17
post #5

The problem with relying on anchors means it stays in the browser history, so if you press 'back', you get the modal dialog again! I don't think this is very useful, but it is a fun exercise in CSS.

Well, you can manipulate the browser history to remove those anchor links :)

Sure, just have the user follow a step-by-step guide on deleting the last x items in their history every time ;-)

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

#137
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.

Shouldn't pure CSS animations have better performance?

If you have a sane amount of JS (ie, not loading entire libraries to accomplish an accordion) the performance differences should be negligible.

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

#138

Earlier quoted context omitted.

What do you exactly mean with "remote-execution-by-default"? As far as I know, all browsers have strict "same-origin" policies by default.

"remote-execution-by-default": web browsers execute code that was loaded from an untrusted source somewhere on the internet. Every (ok, most) browsers by default allow any website you visit to execute JavaScript code in your browser. "same origin" is about the source of that code, only of minor relevance here as long as no working signed code distribution mechanism and infrastructure exists - why not, btw, after all…

> the "sandboxing" approach has been exercised for many years now, mostly without success.

My impression is that Javascript has basically been the most successful sandbox ever deployed on a large scale. All vulnerabilities I've seen that escape the sandbox are due to things like Flash.

Does anybody know of any "JS-only" exploits that have happened?

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

#140
post #42
post #19

Earlier quoted context omitted.

Fortunately you can use animation-delay to simulate bloated Javascript.

It's not about bloat, it's about accidentally triggering menus when you move your mouse down the page.

On the subject on accessibility, I just came across this - note the comment from Brad Martin:

http://terrillthompson.com/blog/474

Post reply on HN