Why Sass or Scss converts color #ffe to #ffffee and add a ";" which could make the css file load slower?
Sass or Scss (.sass) is common in Ruby on Rails projects, but I just found that it converts the color such as:
background: #ffe
into
background: #ffffee;
why the extra bytes? Also, why the extra ;
at the end? Sass should automatically compile into a .css
file, so the "extra semi-colon" at the end can be a good form if the users are editing the CSS file directly, but Sass is about automatic compiling, so why add a ;
to increase page load time?
Second, why the universal accepted #ffe
expanded as #ffffee
? There isn't a modern browser that doesn't understand开发者_StackOverflow it... (maybe except the browser on a low-end cell phone, but those pages are very unreadable anyways.)
Output Sass using the compressed output mode and it will drop the last semicolon and use the more compact version of the color.
E.g.
echo "div { color: #ffe; }" | sass -t compressed --scss
Returns
div{color:#ffe}
Two-fold reasoning. Readability + Consistency. The size difference is negligible, and if you are worried about speed time is better spent optimizing the code / removing repetitive properties rather than worrying about the semicolon. This allows for consistent writing
精彩评论