Node.js module for detecting if any CSS file in a set has more selectors than IE's limit of 4095.
Pass the module an array of CSS file paths and it will analyse each file and invoke a callback function that is passed an array of result objects in the same order of the original array.
There is a grunt and gulp plugin that wraps this module:
var cssSelectorLimit = require('css-selector-limit');
cssSelectorLimit([
__dirname + '/style/default.css'
], function(err, results){
if(err){
//error occurred
}
else if(!results[0].ok){
//number of selectors is over the limit.
}
});
//pass options to function
cssSelectorLimit([
__dirname + '/style/default.css'
], {
limit: 10000
}, function(err, results){
//do something with results.
});
//pass file contents directly
fs.readFile(__dirname + '/style/default.css', {encoding: 'utf-8'}, function(err, file){
cssSelectorLimit([
file
], function(err, results){
//do something with results.
});
});
Type: Number
Default value: 4095
Type: String
Path to the file that was analysed.
Type: Boolean
If the number of selectors is less than or equal to the limit the value will be true else false.
Type: String
Default value: null
The first selector that went over the limit.
Type: Number
Default value: null
The line number of the first selector that went over the limit.
The first selector that went over the limit.
Type: Number
The total number of selectors in the file.