DEV Community

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

Collapse
 
saurabhdaware profile image
Saurabh Daware 🌻

Hi, can you tell me which code-block are you talking about? I will fix it.

Collapse
 
stephenmirving profile image
Stephen Irving • Edited

I'm just giving you a hard time - I liked the article.

This is what I'm talking about though, no spaces before the opening bracket:

function loadProjectImage(e){

You do it in pretty much every code block in the JS and CSS:

html,body{

.lazyload, .main-container{

Like I said though, just giving you a hard time. It is a style thing and I'm pretty anal about style. it was a good article. Thanks.

Thread Thread
 
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...