Last active
August 29, 2015 14:08
-
-
Save limarc/33afce0e2f6b0467b161 to your computer and use it in GitHub Desktop.
Determination of duplicate stylesheets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Поиск дублированных стилей | |
| * | |
| * @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