web staff: log minification
authorBill Erickson <berick@esilibrary.com>
Mon, 16 Dec 2013 16:51:35 +0000 (11:51 -0500)
committerBill Erickson <berick@esilibrary.com>
Mon, 16 Dec 2013 16:51:35 +0000 (11:51 -0500)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
web-staff-log.txt

index 7cb7577..4605d2c 100644 (file)
@@ -1102,6 +1102,60 @@ the story develops....
    break and flow (e.g. for mobile devices) a little too aggressively
    right now.  TODO.
 
+2013-12-16 JS Minification
+--------------------------
+
+Angular has some built-in magic which forces us to take special care when
+preparing for Javascript minification.  For the details, see the "A Note
+On Minification" section of the 
+http://docs.angularjs.org/tutorial/step_05[Angular Totorial Docs].  Briefly,
+there's a short (auto-magic) way and a long way to declare dependencies
+for services, controllers, etc.  To use minificaiton, you have to use the 
+long way.  To make sure everything is working as expected, I've set up 
+a test.
+
+Testing Minification
+~~~~~~~~~~~~~~~~~~~~
+
+ * Download jar file from https://github.com/yui/yuicompressor/releases[YUICompressor Releases]
+ * Create a staff.min.js bundle from commonly loaded files:
+
+[source,sh]
+-----------------------------------------------------------------------------
+% cd /openils/var/web/js/ui/default/staff                                        
+
+# note the files have to be combined in a specific order
+% cat /openils/var/web/js/dojo/opensrf/JSON_v1.js \
+/openils/var/web/js/dojo/opensrf/opensrf.js \
+/openils/var/web/js/dojo/opensrf/opensrf_xhr.js \
+services/core.js \
+services/idl.js \
+services/event.js \
+services/net.js \
+services/auth.js \
+services/pcrud.js \
+services/env.js \
+services/org.js \
+services/startup.js \
+services/ui.js \
+navbar.js \
+| java -jar yuicompressor-2.4.8.jar --type js -o staff.min.js 
+-----------------------------------------------------------------------------
+
+ * modify /openils/var/templates/staff/t_base_js.tt2
+  ** comment out <script> references to the JS files listed above
+  ** add a new <script> tag for staff.min.js
+[source,html]
+-----------------------------------------------------------------------------
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/staff.min.js"></script>
+-----------------------------------------------------------------------------
+
+ * Reload the page. 
+
+I'm happy to report all pages load successfully with (mostly) minimized JS.
+Next on the minification front would be baking minification into the
+release-building process.
+
 Future Topics...
 ----------------