Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: tools/grit/grit/format/minifier.py

Issue 2179033002: Strip comments and whitespace from javascript resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert changes to screen.js (no longer needed for this CL) Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/grit/grit/format/html_inline.py ('k') | tools/grit/grit/gather/chrome_html.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 """Framework for stripping whitespace and comments from resource files"""
5
6 import subprocess
7
8 __js_minifier = None
9
10
11 def SetJsMinifier(minifier):
12 global __js_minifier
13 __js_minifier = minifier.split()
14
15
16 def Minify(source, file_type):
17 if not file_type == '.js' or not __js_minifier:
18 return source
19 p = subprocess.Popen(
20 __js_minifier,
21 stdin=subprocess.PIPE,
22 stdout=subprocess.PIPE,
23 stderr=subprocess.PIPE)
24 (stdout, stderr) = p.communicate(source)
25 if stderr:
26 print stderr
27 if p.returncode != 0:
28 print 'Minification failed, using original source'
29 return source
30 return stdout
OLDNEW
« no previous file with comments | « tools/grit/grit/format/html_inline.py ('k') | tools/grit/grit/gather/chrome_html.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698