DEV Community

Discussion on: I rebuilt my portfolio๐ŸŒป Now it loads in 1.6s ๐ŸŽ‰ Here's how I did

 
saurabhdaware profile image
Saurabh Daware ๐ŸŒป

Oh I see. I think it totally depends on how you (and your team) prefer it.
I've seen a lot of w3 articles not putting any space there. Even a lot of code snippets in this article about JavaScript best practices - w3.org/wiki/JavaScript_best_practices do not add any space in the code.

So yeah it depends on how you are linting that particular project :)

Thread Thread
 
saurabhdaware profile image
Saurabh Daware ๐ŸŒป

Just checked google.github.io/styleguide/jsguid... and yes they mentioned about the space before brackets :D

Thread Thread
 
stephenmirving profile image
Stephen Irving

Too funny! I was just about to link the Google style guide for you. Ya, Douglas Crockford recommends it as well: crockford.com/code.html
As well as every other style guide I've seen. Interesting that the w3 best practices doc writes them that way, I hadn't seen that.

On another note, I've also seen it said that it is against best practices to pass the event object around. Here is a link to the page of the book I saw it in, Maintainable JavaScript, thought you may be interested (it is a very good book too, I always recommend it, as well as JavaScript Patterns by Stoyan and JavaScript The Good Parts by Crockford:

books.google.com/books?id=bHhlCrvb...