Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Stop minifying JavaScript and templates inline because it's not async.

  • Loading branch information...
commit 33132ccfeb98e49bb4e2860602ec9c4b64cad195 1 parent fe55329
Eric Ferraiuolo authored

Showing 1 changed file with 14 additions and 6 deletions. Show diff stats Hide diff stats

  1. 20  app.js
20  app.js
@@ -49,8 +49,9 @@ app.configure('development', function () {
49 49
 });
50 50
 
51 51
 app.configure('production', function () {
52  
-    // Only minify templates in production.
53  
-    app.enable('minify templates');
  52
+    // Renable these when minification is done async!
  53
+    // app.enable('minify templates');
  54
+    // app.enable('minify js');
54 55
 
55 56
     app.enable('view cache');
56 57
     app.use(express.errorHandler());
@@ -73,7 +74,15 @@ app.get('/combo', combo.combine({rootPath: pubDir + '/js'}), function (req, res)
73 74
         }
74 75
     }
75 76
 
76  
-    res.send(res.body, 200);
  77
+    var js = res.body,
  78
+        minify;
  79
+
  80
+    if (app.enabled('minify js')) {
  81
+        minify = require('uglify-js');
  82
+        js     = minify(js);
  83
+    }
  84
+
  85
+    res.send(js, 200);
77 86
 });
78 87
 
79 88
 // Dymanic resource for precompiled templates.
@@ -95,13 +104,12 @@ app.get('/templates.js', function (req, res, next) {
95 104
     }, function (err, view) {
96 105
         if (err) { return next(); }
97 106
 
98  
-        var minify, templates;
  107
+        var templates = view,
  108
+            minify;
99 109
 
100 110
         if (app.enabled('minify templates')) {
101 111
             minify    = require('uglify-js');
102 112
             templates = minify(view);
103  
-        } else {
104  
-            templates = view;
105 113
         }
106 114
 
107 115
         res.send(templates, {

0 notes on commit 33132cc

Please sign in to comment.
Something went wrong with that request. Please try again.