Cssnano Postcss-Merge-Rules

Cssnano Postcss-Merge-Rules

cssnano modular minifier Ben Briggs Why write another minifier? Other projects exist, do we need to reinvent the wheel? cssnano Performance considerations? If a file can be made smaller, without breaking its syntax, then it should be. Let us consider places where Internet connectivity is less reliable than ours. cssnano Existing tools lack consistency. Why should it be that CSS run through different tools produces different results? cssnano (demo) cssnano Tools should be smart. cssnano uses the PostCSS parser, written in JavaScript, which is 3 times faster than libsass, written in C++. No huge regular expressions. cssnano Minifying is too broad a scope. Many existing tools are very opinionated, and are responsible for too many tasks. cssnano Modularity is king. npm taught us to extract functionality into separate modules, and publish at will. Why should a minifier be excluded from this philosophy? cssnano postcss-merge-rules postcss-discard-font-face postcss-calc postcss-single-charset postcss-zindex postcss-convert-values postcss-discard-duplicates postcss-reduce-idents cssnano postcss-normalize-url postcss-discard-comments postcss-font-family postcss-minify-selectors postcss-minify-font-weight postcss-pseudoelements postcss-colormin postcss-discard-empty cssnano postcss-merge-rules postcss-discard-font-face postcss-zindex postcss-convert-values postcss-discard-duplicates postcss-reduce-idents cssnano postcss-normalize-url postcss-discard-comments postcss-font-family postcss-minify-selectors postcss-minify-font-weight postcss-colormin postcss-discard-empty cssnano What can it compress? cssnano covers many optimisations – this is a breakdown of the more unconventional approaches. cssnano postcss-merge-rules a { a, h1 { color: black; color: black; font-weight: bold font-weight: bold } } h1 { color: black; font-weight: bold } cssnano postcss-normalize-url .one { background: url("http://site.com:80/css/../image.jpg") } .one { background: url(http://site.com/image.jpg) } cssnano postcss-reduce-idents @keyframes whiteToBlack { @keyframes a { 0% { 0% { color: #fff color: #fff } } to { to { color: #000 color: #000 } } } } .one { .one { animation-name: whiteToBlack animation-name: a } } cssnano postcss-zindex .one { .one { z-index: 1000 z-index: 2 } } .two { .two { z-index: 500 z-index: 1 } } .three { .three { z-index: 2500 z-index: 3 } } cssnano html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size- adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,sum mary{display:block}audio,canvas,progress,video{display:inline-block;vertical- align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background- color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font- weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font- size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:- .5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit- box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content- box}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace;font- size:1em}button,input,optgroup,select,textarea{margin:0;font:inherit;color:inherit}button{overflow:visible}butto n,select{text-transform:none}button,html input[type="button"],input[type=reset],input[type=submit]{-webkit- appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus- inner,input::-moz-focus-inner{padding:0;border:0}input{line- height:normal}input[type=checkbox],input[type=radio]{-webkit-box-sizing:border-box;-moz-box-sizing:border- box;box-sizing:borderIt-box;padding:0}input[type="number"]:: does whitespace-webkit-inner-spin-button,input too![type="number"]::- webkit-outer-spin-button{height:auto}input[type=search]{-webkit-box-sizing:content-box;-moz-box-sizing:content- box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-cancel- button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid silver}legend{padding:0;border:0}textarea{overflow:auto}optgroup{font- weight:700}table{border-spacing:0;border-collapse:collapse}td,th{padding:0}/*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */@media print{*,:after,:before{color:#000!important;text-shadow:none!important;background:transparent!important;-webkit- box-shadow:none!important;box-shadow:none!important}a,a:visited{text- decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}a[href^="#"]:after,a[href^="javascript:"]:after{content:""}blockquote,pre{border:1px solid #999;page-break- inside:avoid}thead{display:table-header-group}img,tr{page-break-inside:avoid}img{max- width:100%!important}h2,h3,p{orphans:3;widows:3}h2,h3{page-break- after:avoid}.navbar{display:none}.btn>.caret,.dropup>.btn>.caret{border-top- color:#000!important}.label{border:1px solid #000}.table{border-collapse:collapse!important} cssnano Built for collaboration. There are optimisations that are not covered. It is important to get feedback from the community to progress the state of the art of CSS compression. cssnano Project Links • cssnano homepage https://github.com/ben-eb/cssnano • css-minifier-tests https://github.com/ben-eb/css-minifier-tests • broccoli-cssnano https://github.com/sindresorhus/broccoli-cssnano • gulp-cssnano https://github.com/ben-eb/gulp-cssnano • grunt-cssnano https://github.com/sindresorhus/grunt-cssnano • postcss https://github.com/postcss/postcss cssnano Any Questions? cssnano.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    19 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us