: Does Google care about code formatting? TLDR; Does Google care how code is formatted? Background I work in an agency. One developer is trying to convince the other to put line-breaks between
TLDR;
Does Google care how code is formatted?
Background
I work in an agency. One developer is trying to convince the other to put line-breaks between rules in his css file:
.class {
width:100%;
height:auto;
}
as opposed to inline: .class { width:100%; height:auto; }
The argument is that it reduces the file-size, to which the counter-argument is "we're minifying the css" afterward.
The last argument is "Google cares about how code is formatted" and presented the following link google.github.io/styleguide/htmlcssguide.xml
We pointed out that one of the last points at the bottom of the page is that css rules must have line breaks in them:
Always put a blank line (two line breaks) between rules.
html {
background: #fff ;
}
body {
margin: auto;
width: 50%;
}
Even with his own argument blown out of the water he is still adamant that Google cares about css, html etc being minified and inline.
Which leads to my question (looking for an authoritative answer - links to official Google website required) - Does Google care how code is formatted?
My personal answer is "No", otherwise Google wouldn't be telling us minifying our code to reduce load time on mobile devices etc.
More posts by @Deb1703797
2 Comments
Sorted by latest first Latest Oldest Best
Google will always care about your load time, because it is one of the most important user experience definitive.
According to Akamai research, 47% of the users expect the website to load in 2 seconds, and 57% of the users will leave the page if it doesn't load in 3 seconds.
!Google crawler will cancel the page indexing either if the page doesn't load in 3 seconds!
“A search result for a resource having a short load time relative to
resources having longer load times can be promoted in a presentation
order, and search results for the resources having longer load times
can be demoted.”
It's a good practice to have 2 CSS files, but only 1 active, basically you create your CSS file human readable after your project is completed you backup your CSS on your desktop or a folder for this purpose, leaving the copy aside you should minify the CSS which is still on the website and leave it minified so it can be served faster, and this part isn't my favourite but for every update of the css you are making in future you need to add the changes to both CSS files OR you need to backup the backup and minify the original again.
Your co-worker is both wrong and right about it, if you want to orientate better in your code it's good to have line breaks between the rules, but it will take more time for the code to be served, because the bigger the code is, the bigger problems you have, which is really bad.
That whole article is about making code readable for humans and has nothing to do with SEO.
Google does not care about formatting. Google only cares about content. Anything that helps outline that content, such as proper headings to show them where a new section begins and lists, will help them figure out what your content is about and where it begins and ends.
Every company and every person has their own style of writing code. Google does not dictate or suggest you change that but tries to give what they consider best practices or good ideas.
take a few minutes to look at the code around you and determine its
style. If they use spaces around all their arithmetic operators, you
should too.
You are free to ignore them or accept them as you wish.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.