Skip to content

Instantly share code, notes, and snippets.

@limarc
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save limarc/33afce0e2f6b0467b161 to your computer and use it in GitHub Desktop.

Select an option

Save limarc/33afce0e2f6b0467b161 to your computer and use it in GitHub Desktop.
Determination of duplicate stylesheets
/**
* Поиск дублированных стилей
*
* @param {Mixed} collection Коллекция
*/
function duplicates(collection) {
var maps = [], path = '', key = 0;
if (!Array.isArray(collection)) {
collection = [].slice.apply(collection);
}
collection.forEach(function(resource) {
path = resource.href || resource.src;
if (!path) {
return;
}
if (maps.indexOf(path) !== -1) {
return console.info(
'%cDuplicate resource: ' + path,
'background: yellow; color: #000; font-weight: 700; padding: 1px 4px;'
);
}
maps.push(path);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment