From 1008ec19c750f80b8d4bc6b7182948aa8d2599f5 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Mon, 22 Jul 2013 20:24:42 -0400 Subject: [PATCH] file size experiments; possible 36% savings --- closure-todo.txt | 1 + dygraph-exports.js | 43 ++++++++++++++++++++++++++++++++++++++++++- generate-combined.sh | 10 ++++++---- tests/demo.html | 3 +++ tests/demo.js | 0 5 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 tests/demo.js diff --git a/closure-todo.txt b/closure-todo.txt index 10dcead..ddc3a1d 100644 --- a/closure-todo.txt +++ b/closure-todo.txt @@ -38,3 +38,4 @@ As each file is closurized, it can be added as a "--js" parameter. NOTES - Should add .getNumericOption() and .getStringOption() which are aliases for .getOption() but returns number/string, not *. +- plugin-free code is 52778 compiled; for uglifyjs it's 83031 (36% savings) diff --git a/dygraph-exports.js b/dygraph-exports.js index 3bcf8d5..f542c45 100644 --- a/dygraph-exports.js +++ b/dygraph-exports.js @@ -1,3 +1,44 @@ goog.exportSymbol('Dygraph', Dygraph); -goog.exportSymbol('Dygraph.prototype.updateOptions', Dygraph.prototype.updateOptions); + +goog.exportSymbol('Dygraph.prototype.adjustRoll', Dygraph.prototype.adjustRoll); +goog.exportSymbol('Dygraph.prototype.annotations', Dygraph.prototype.annotations); +goog.exportSymbol('Dygraph.prototype.clearSelection', Dygraph.prototype.clearSelection); goog.exportSymbol('Dygraph.prototype.destroy', Dygraph.prototype.destroy); +goog.exportSymbol('Dygraph.prototype.eventToDomCoords', Dygraph.prototype.eventToDomCoords); +goog.exportSymbol('Dygraph.prototype.getArea', Dygraph.prototype.getArea); +goog.exportSymbol('Dygraph.prototype.getColors', Dygraph.prototype.getColors); +goog.exportSymbol('Dygraph.prototype.getHighlightSeries', Dygraph.prototype.getHighlightSeries); +goog.exportSymbol('Dygraph.prototype.getLabels', Dygraph.prototype.getLabels); +goog.exportSymbol('Dygraph.prototype.getOption', Dygraph.prototype.getOption); +goog.exportSymbol('Dygraph.prototype.getPropertiesForSeries', Dygraph.prototype.getPropertiesForSeries); +goog.exportSymbol('Dygraph.prototype.getSelection', Dygraph.prototype.getSelection); +goog.exportSymbol('Dygraph.prototype.getValue', Dygraph.prototype.getValue); +goog.exportSymbol('Dygraph.prototype.indexFromSetName', Dygraph.prototype.indexFromSetName); +goog.exportSymbol('Dygraph.prototype.isSeriesLocked', Dygraph.prototype.isSeriesLocked); +goog.exportSymbol('Dygraph.prototype.isZoomed', Dygraph.prototype.isZoomed); +goog.exportSymbol('Dygraph.prototype.numAxes', Dygraph.prototype.numAxes); +goog.exportSymbol('Dygraph.prototype.numColumns', Dygraph.prototype.numColumns); +goog.exportSymbol('Dygraph.prototype.numRows', Dygraph.prototype.numRows); +goog.exportSymbol('Dygraph.prototype.resetZoom', Dygraph.prototype.resetZoom); +goog.exportSymbol('Dygraph.prototype.resize', Dygraph.prototype.resize); +goog.exportSymbol('Dygraph.prototype.rollPeriod', Dygraph.prototype.rollPeriod); +goog.exportSymbol('Dygraph.prototype.setAnnotations', Dygraph.prototype.setAnnotations); +goog.exportSymbol('Dygraph.prototype.setSelection', Dygraph.prototype.setSelection); +goog.exportSymbol('Dygraph.prototype.setVisibility', Dygraph.prototype.setVisibility); +goog.exportSymbol('Dygraph.prototype.toDataCoords', Dygraph.prototype.toDataCoords); +goog.exportSymbol('Dygraph.prototype.toDataXCoord', Dygraph.prototype.toDataXCoord); +goog.exportSymbol('Dygraph.prototype.toDataYCoord', Dygraph.prototype.toDataYCoord); +goog.exportSymbol('Dygraph.prototype.toDomCoords', Dygraph.prototype.toDomCoords); +goog.exportSymbol('Dygraph.prototype.toDomXCoord', Dygraph.prototype.toDomXCoord); +goog.exportSymbol('Dygraph.prototype.toDomYCoord', Dygraph.prototype.toDomYCoord); +goog.exportSymbol('Dygraph.prototype.toPercentXCoord', Dygraph.prototype.toPercentXCoord); +goog.exportSymbol('Dygraph.prototype.toPercentYCoord', Dygraph.prototype.toPercentYCoord); +goog.exportSymbol('Dygraph.prototype.toString', Dygraph.prototype.toString); +goog.exportSymbol('Dygraph.prototype.updateOptions', Dygraph.prototype.updateOptions); +goog.exportSymbol('Dygraph.prototype.visibility', Dygraph.prototype.visibility); +goog.exportSymbol('Dygraph.prototype.xAxisExtremes', Dygraph.prototype.xAxisExtremes); +goog.exportSymbol('Dygraph.prototype.xAxisRange', Dygraph.prototype.xAxisRange); +goog.exportSymbol('Dygraph.prototype.yAxisRange', Dygraph.prototype.yAxisRange); +goog.exportSymbol('Dygraph.prototype.yAxisRanges', Dygraph.prototype.yAxisRanges); + +goog.exportSymbol('Dygraph.Plotters', Dygraph.Plotters); diff --git a/generate-combined.sh b/generate-combined.sh index c4a40f2..f1a7260 100755 --- a/generate-combined.sh +++ b/generate-combined.sh @@ -14,13 +14,13 @@ GetSources () { dygraph-gviz.js \ dygraph-interaction-model.js \ dygraph-tickers.js \ - dygraph-plugin-base.js \ - plugins/*.js \ - dygraph-plugin-install.js + dygraph-plugin-base.js do echo "$F" done } +# plugins/*.js \ +# dygraph-plugin-install.js # Pack all the JS together. CatSources () { @@ -36,7 +36,9 @@ Copyright () { CatMinified () { Copyright CatSources \ - | uglifyjs - -c 'warnings=false' -m + | java -jar ../../closure-compiler-read-only/build/compiler.jar --js ../../closure-library-read-only/closure/goog/base.js --js - --compilation_level ADVANCED_OPTIMIZATIONS --warning_level VERBOSE --externs dygraph-externs.js --externs gviz-api.js --output_wrapper='(function() {%output%})();' + + #| uglifyjs - -c 'warnings=false' -m # | java -jar yuicompressor-2.4.2.jar --type js } diff --git a/tests/demo.html b/tests/demo.html index 9184f4c..8fa6fde 100644 --- a/tests/demo.html +++ b/tests/demo.html @@ -6,7 +6,10 @@ + +

Demo

diff --git a/tests/demo.js b/tests/demo.js new file mode 100644 index 0000000..e69de29 -- 2.7.4