GithubHelp home page GithubHelp logo

grunt-css-metrics's People

Contributors

aki77 avatar kaelig avatar phamann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

grunt-css-metrics's Issues

Comments are included in rule count

Comments end up in the rule count. This is because css-parse puts comments in the rules array, and css-metrics just passes the array length as the rule count value.

See line 30 of css-metrics.js

    rules: function() {
        return this.parsedData.rules.length;
    },

Should be an easy fix with a little array jiggering.

I made a wee test project to validate this:
https://github.com/tehfoo/css-metrics-testing

I'll pull request a fix for this when I get a spare few minutes, unless someone beats me to it.

Lacks static mapping to be loaded with JIT Grunt

I'm using https://www.npmjs.org/package/jit-grunt which allows on-demand loading with a single instruction at the beginning of gruntfile,js (require('jit-grunt')(grunt))

However grunt cssmetrics doesn't work by default:

jit-grunt: Plugin for the "cssmetrics" task not found.
If you have installed the plugin already, please setting the static mapping.
See https://github.com/shootaroo/jit-grunt#static-mappings

Warning: Task "cssmetrics" not found. Use --force to continue.

Just to rule out that there's something wrong with my setup, other tasks (concat, uglify, jshint et. al.) work, and cssmetrics works if I load it the traditional way with grunt.loadNpmTasks('grunt-css-metrics')

This can be easily resolved with the jit-grunt loader (see following link), but I thought I'd mention it.
https://github.com/shootaroo/jit-grunt#static-mappings

Media queries are not counted properly

Here's a test case: http://codepen.io/anon/pen/GEcmx

The CSS file contains 4100 rules, and 4101 selectors. 100 of those rules are nested inside two media queries.

grunt-css-metrics gives the following result:

>> Total rules: 4003
>> Total selectors: 4001
>> Average selectors per rule: 1
>> File size: 136.76 KB
>> GZip size: 9.75 KB

Looks like grunt-css-metrics evaluates the media query as a rule, but not the contents of the media query.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.