Skip to content

Instantly share code, notes, and snippets.

@og-shawn-crigger
Created February 6, 2015 21:31
Show Gist options
  • Save og-shawn-crigger/faac8b97c7a1cd57c60d to your computer and use it in GitHub Desktop.
Save og-shawn-crigger/faac8b97c7a1cd57c60d to your computer and use it in GitHub Desktop.
Creates a array of all the scripts and styles and outputs them in json format in the console
//DOM ELEMENTS
clear();
var scripts = [];
var styles = [];
console.groupCollapsed('CSS Links');
console.log("Loop start.");
jQuery("link").each(function(index, value) {
var link = jQuery(this).attr('href');
console.log( typeof link );
if ( typeof link !== 'undefined' || '' != link || 'undefined' !== link ) {
console.log('link' + index + ':' + link );
styles.push( link );
}
});
console.log("Loop end.");
console.groupEnd();
console.groupCollapsed('JS Links');
console.log("Loop start.");
jQuery("script").each(function(index, value) {
var link = jQuery(this).attr('src');
console.log( typeof link );
if ( typeof link !== 'undefined' || '' != link || 'undefined' !== link ) {
console.log('script' + index + ':' + link );
scripts.push( link );
}
});
console.log("Loop end.");
console.groupEnd();
//scripts = jQuery(scripts).serializeArray();
//styles = jQuery(styles).serializeArray();
console.log( scripts );
console.log( styles );
console.save( scripts, 'kk-scripts.json' );
console.save( styles, 'kk-styles.json' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment