mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Landing pull request 511. Adding a little Makefile jQuery sizing utility to easily see differences in size between makes. Fixes #10308.
More Details: - https://github.com/jquery/jquery/pull/511
This commit is contained in:
parent
8f447576c9
commit
61277d2864
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@ dist
|
|||||||
*.patch
|
*.patch
|
||||||
/*.html
|
/*.html
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
build/.sizecache.json
|
||||||
|
12
Makefile
12
Makefile
@ -44,7 +44,7 @@ DATE=$(shell git log -1 --pretty=format:%ad)
|
|||||||
|
|
||||||
all: update_submodules core
|
all: update_submodules core
|
||||||
|
|
||||||
core: jquery min lint
|
core: jquery min lint size
|
||||||
@@echo "jQuery build complete."
|
@@echo "jQuery build complete."
|
||||||
|
|
||||||
${DIST_DIR}:
|
${DIST_DIR}:
|
||||||
@ -73,6 +73,15 @@ lint: jquery
|
|||||||
echo "You must have NodeJS installed in order to test jQuery against JSLint."; \
|
echo "You must have NodeJS installed in order to test jQuery against JSLint."; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
size: jquery min
|
||||||
|
@@if test ! -z ${JS_ENGINE}; then \
|
||||||
|
gzip -c ${JQ_MIN} > ${JQ_MIN}.gz; \
|
||||||
|
wc -c ${JQ} ${JQ_MIN} ${JQ_MIN}.gz | ${JS_ENGINE} ${BUILD_DIR}/sizer.js; \
|
||||||
|
rm ${JQ_MIN}.gz; \
|
||||||
|
else \
|
||||||
|
echo "You must have NodeJS installed in order to size jQuery."; \
|
||||||
|
fi
|
||||||
|
|
||||||
min: jquery ${JQ_MIN}
|
min: jquery ${JQ_MIN}
|
||||||
|
|
||||||
${JQ_MIN}: ${JQ}
|
${JQ_MIN}: ${JQ}
|
||||||
@ -84,7 +93,6 @@ ${JQ_MIN}: ${JQ}
|
|||||||
else \
|
else \
|
||||||
echo "You must have NodeJS installed in order to minify jQuery."; \
|
echo "You must have NodeJS installed in order to minify jQuery."; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@@echo "Removing Distribution directory:" ${DIST_DIR}
|
@@echo "Removing Distribution directory:" ${DIST_DIR}
|
||||||
|
36
build/sizer.js
Normal file
36
build/sizer.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
var fs = require( "fs" ),
|
||||||
|
stdin = process.openStdin(),
|
||||||
|
rsize = /(\d+).*?(jquery\S+)/g,
|
||||||
|
oldsizes = {},
|
||||||
|
sizes = {};
|
||||||
|
|
||||||
|
try {
|
||||||
|
oldsizes = JSON.parse( fs.readFileSync( __dirname + "/.sizecache.json", "utf8" ) );
|
||||||
|
} catch(e) {
|
||||||
|
oldsizes = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
stdin.on( "data" , function( chunk ) {
|
||||||
|
var match;
|
||||||
|
|
||||||
|
while ( match = rsize.exec( chunk ) ) {
|
||||||
|
sizes[ match[2] ] = parseInt( match[1], 10 );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function lpad( str, len, chr ) {
|
||||||
|
return ( Array(len+1).join( chr || " ") + str ).substr( -len );
|
||||||
|
}
|
||||||
|
|
||||||
|
stdin.on( "end", function() {
|
||||||
|
console.log( "jQuery Size - compared to last make" );
|
||||||
|
fs.writeFileSync( __dirname + "/.sizecache.json", JSON.stringify( sizes, true ), "utf8" );
|
||||||
|
for ( var key in sizes ) {
|
||||||
|
var diff = oldsizes[ key ] && ( sizes[ key ] - oldsizes[ key ] );
|
||||||
|
if ( diff > 0 ) {
|
||||||
|
diff = "+" + diff;
|
||||||
|
}
|
||||||
|
console.log( "%s %s %s", lpad( sizes[ key ], 8 ), lpad( diff ? "(" + diff + ")" : "(-)", 8 ), key );
|
||||||
|
}
|
||||||
|
process.exit();
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user