css-selector-limit
Node.js module for detecting if any CSS file in a set has more selectors than IE's limit of 4095.
Overview
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){
}
else if(!results[0].ok){
}
});
cssSelectorLimit([
__dirname + '/style/default.css'
], {
limit: 10000
}, function(err, results){
});
fs.readFile(__dirname + '/style/default.css', {encoding: 'utf-8'}, function(err, file){
cssSelectorLimit([
file
], function(err, results){
});
});
Options
options.limit
Type: Number
Default value: 4095
Result Object
result.file
Type: String
Path to the file that was analysed.
result.ok
Type: Boolean
If the number of selectors is less than or equal to the limit the value will be true else false.
result.selector
Type: String
Default value: null
The first selector that went over the limit.
result.line
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.
result.count
Type: Number
The total number of selectors in the file.