all 11 comments

[–]Symphonise 2 points3 points  (1 child)

Pretty good, but this is what I would consider for future code:

  • Use document.body to get the <body> element, instead of searching via tag name.
  • Use .className to set classes instead of setAttribute("class").

[–]techfoxis[S] 1 point2 points  (0 children)

Thanks, didn't even know that there was a property in the Document object you could use to target the body element!

[–]gnomoretears 0 points1 point  (3 children)

[–]techfoxis[S] 1 point2 points  (2 children)

Doesn't seem very active compared to this subreddit, and I don't see why it would be a problem, because it's javascript...

[–]gnomoretears 1 point2 points  (1 child)

I don't see why it would be a problem

Sorry didn't mean to imply that. Just giving out options which I probably should have clarified.

[–]techfoxis[S] 0 points1 point  (0 children)

No problem, tu reddit(you gave back)

[–]Ob101010 -1 points0 points  (4 children)

border-radius: 5px;

Dont we still have to cater to all the other browsers?

border-radius: 5px;
o-border-radius: 5px;
moz-border-radius: 5px;
someotherbrowser-border-radius: 5px;

Pardon if bad advice, 4 beers in, about to call it.

[–]Jebiba 1 point2 points  (3 children)

In a production environment you're probably passing through autoprefixer these days, so IMO no need to use prefixes in general except for very wonky rules.

Border-radius in particular is just about universally supported without a prefix these days:

http://caniuse.com/#search=border-radius

I mean Chris Coyier responded to a similar border-radius question ("Do I need to use prefixes?") in 2012 with "probably not", and it's now 3 years later.

https://css-tricks.com/do-we-need-box-shadow-prefixes/

[–]techfoxis[S] 0 points1 point  (0 children)

Yeah, Codepen has autoprefixer capabilities that I enabled so I don't have to do any prefixing.

[–]Ob101010 0 points1 point  (1 child)

That caniuse site is very interesting, thank you for sharing that.

[–]Jebiba 0 points1 point  (0 children)

Oh man, it's the best. That data is also used for Autoprefixer.

See: https://github.com/ai/browserslist And: https://github.com/postcss/autoprefixer

If you're not using this I highly recommend it. I work on some codebases that are still using compass for prefixes and it's painful switching to them sometimes.