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

Issue 2094193004: Strip comments and whitespace from Javascript resources (Closed)

Created:
4 years, 5 months ago by aberent
Modified:
4 years, 4 months ago
CC:
agrieve, Bernhard Bauer, brettw, chromium-reviews, Torne
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Strip comments and whitespace from Javascript resources This CL creates the infrastructure to strip comments and spaces from Javascript resources, and uses this infrastructure on the components and browser resources, hence reducing the size of each pak file by around 20% (total reduction ~340KB) The CL uses the Closure compiler to strip spaces and comments. Because this may be slow, the CL uses ninja (via GN) to only run it on changed Javascript resources. To do this the resources are processed in three stages: 1) Strip <include..> and <if...> blocks. These are not part of Javascript and can't be handled by the compiler. 2) Run the Closure compiler 3) Run grit, creating the resource file. To enable this sequence this CL adds an argument to grit that tells it the location of preprocessed (and hence moved) files. At present this is only implemented on Android builds, since the builders for other platforms may not have Java, which is required to run the closure compiler. BUG=619091

Patch Set 1 #

Patch Set 2 : Fix some silly errors #

Patch Set 3 : Fix setting platform when not cross-compiling #

Patch Set 4 : Disable on everything except Android #

Patch Set 5 : Fix non-Android builds #

Patch Set 6 : Add test for flattener, move code to grit subdirectory #

Patch Set 7 : Also strip Javascript browser resources #

Total comments: 22

Patch Set 8 : Respond to comments, plus rebases. #

Total comments: 9
Unified diffs Side-by-side diffs Delta from patch set Stats (+504 lines, -45 lines) Patch
M build/config/features.gni View 1 2 3 4 5 6 7 1 chunk +4 lines, -0 lines 0 comments Download
M chrome/browser/BUILD.gn View 1 2 3 4 5 6 7 1 chunk +118 lines, -1 line 0 comments Download
M components/resources/BUILD.gn View 2 chunks +45 lines, -7 lines 0 comments Download
M third_party/closure_compiler/README.chromium View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M third_party/closure_compiler/closure_args.gni View 1 2 3 4 5 6 7 3 chunks +9 lines, -10 lines 0 comments Download
M third_party/closure_compiler/compile2.py View 1 2 3 4 5 6 7 2 chunks +2 lines, -2 lines 1 comment Download
A third_party/closure_compiler/compile_js2.gni View 1 2 3 4 5 6 7 1 chunk +35 lines, -0 lines 0 comments Download
A + tools/grit/flatten_resource.py View 1 2 3 4 5 2 chunks +3 lines, -3 lines 0 comments Download
A tools/grit/grit/flatten_resource_runner.py View 1 2 3 4 5 6 7 1 chunk +91 lines, -0 lines 1 comment Download
A tools/grit/grit/flatten_resource_runner_unittest.py View 1 2 3 4 5 1 chunk +47 lines, -0 lines 5 comments Download
M tools/grit/grit/format/html_inline.py View 8 chunks +13 lines, -11 lines 0 comments Download
M tools/grit/grit/gather/chrome_html.py View 1 chunk +1 line, -1 line 0 comments Download
M tools/grit/grit/node/include.py View 1 chunk +2 lines, -1 line 0 comments Download
M tools/grit/grit/test_suite_all.py View 1 2 3 4 5 2 chunks +2 lines, -0 lines 0 comments Download
M tools/grit/grit/tool/build.py View 1 2 3 4 5 6 7 6 chunks +17 lines, -1 line 0 comments Download
M tools/grit/grit/util.py View 3 chunks +9 lines, -1 line 0 comments Download
M tools/grit/grit_rule.gni View 1 2 3 4 5 6 7 8 chunks +103 lines, -2 lines 1 comment Download
M ui/login/screen.js View 1 2 3 4 5 6 7 1 chunk +2 lines, -5 lines 1 comment Download

Messages

Total messages: 53 (18 generated)
aberent
jochen@chromium.org: Please review changes in components/resources thestig@chromium.org: Please review changes in tools/grit This is an ...
4 years, 5 months ago (2016-06-27 15:11:42 UTC) #3
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2094193004/20001
4 years, 5 months ago (2016-06-27 16:25:43 UTC) #5
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: mac_chromium_compile_dbg_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_compile_dbg_ng/builds/225274)
4 years, 5 months ago (2016-06-27 16:41:51 UTC) #7
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2094193004/40001
4 years, 5 months ago (2016-06-27 17:07:51 UTC) #9
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_ng/builds/245935)
4 years, 5 months ago (2016-06-27 17:53:48 UTC) #11
Dirk Pranke
+dbeam There's an ongoing effort to use the Closure compiler more broadly that dbeam@ has ...
4 years, 5 months ago (2016-06-27 23:25:27 UTC) #13
Dan Beam
you should probably merge logic to handle <if> and <include> with https://cs.chromium.org/chromium/src/third_party/closure_compiler/processor.py?l=49 if it's helpful ...
4 years, 5 months ago (2016-06-28 02:45:18 UTC) #15
aberent
On 2016/06/28 02:45:18, Dan Beam wrote: > you should probably merge logic to handle <if> ...
4 years, 5 months ago (2016-06-28 08:54:02 UTC) #16
aberent
On 2016/06/28 08:54:02, aberent wrote: > On 2016/06/28 02:45:18, Dan Beam wrote: > > you ...
4 years, 5 months ago (2016-06-28 09:54:49 UTC) #17
jochen (gone - plz use gerrit)
will rubberstamp components once the main part of the CL is reviewed
4 years, 5 months ago (2016-06-28 13:14:41 UTC) #18
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2094193004/60001
4 years, 5 months ago (2016-06-28 14:03:20 UTC) #20
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: mac_chromium_compile_dbg_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_compile_dbg_ng/builds/225959) mac_chromium_rel_ng on ...
4 years, 5 months ago (2016-06-28 14:06:46 UTC) #22
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2094193004/80001
4 years, 5 months ago (2016-06-28 14:33:39 UTC) #26
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_chromium_chromeos_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_chromeos_rel_ng/builds/235671)
4 years, 5 months ago (2016-06-28 15:17:39 UTC) #28
Dan Beam
On 2016/06/28 09:54:49, aberent wrote: > On 2016/06/28 08:54:02, aberent wrote: > > On 2016/06/28 ...
4 years, 5 months ago (2016-06-28 19:25:28 UTC) #29
Dan Beam
On 2016/06/28 08:54:02, aberent wrote: > On 2016/06/28 02:45:18, Dan Beam wrote: > > you ...
4 years, 5 months ago (2016-06-28 19:28:44 UTC) #31
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2094193004/100001
4 years, 5 months ago (2016-06-28 19:29:45 UTC) #32
aberent
On 2016/06/28 19:25:28, Dan Beam wrote: > On 2016/06/28 09:54:49, aberent wrote: > > On ...
4 years, 5 months ago (2016-06-28 19:31:35 UTC) #33
aberent
> you could probably [fairly easily] override our closure_args > https://cs.chromium.org/chromium/src/third_party/closure_compiler/closure_args.gni?q=closure_args&sq=package:chromium&l=6&dr=C > > ^ we ...
4 years, 5 months ago (2016-06-28 19:38:09 UTC) #34
Dan Beam
On 2016/06/28 19:38:09, aberent wrote: > > you could probably [fairly easily] override our closure_args ...
4 years, 5 months ago (2016-06-28 20:37:45 UTC) #35
Dirk Pranke
On 2016/06/28 20:37:45, Dan Beam wrote: > On 2016/06/28 19:38:09, aberent wrote: > > > ...
4 years, 5 months ago (2016-06-28 20:53:33 UTC) #36
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 5 months ago (2016-06-28 21:17:25 UTC) #38
aberent
On 2016/06/28 20:37:45, Dan Beam wrote: > On 2016/06/28 19:38:09, aberent wrote: > > > ...
4 years, 5 months ago (2016-06-29 10:42:35 UTC) #39
aberent
PTAL. Note that I have added stripping browser resources to the CL. This saves a ...
4 years, 5 months ago (2016-06-29 20:03:35 UTC) #41
Dan Beam
On 2016/06/29 10:42:35, aberent wrote: > On 2016/06/28 20:37:45, Dan Beam wrote: > > On ...
4 years, 5 months ago (2016-06-29 22:20:57 UTC) #42
Lei Zhang
https://codereview.chromium.org/2094193004/diff/120001/chrome/browser/BUILD.gn File chrome/browser/BUILD.gn (right): https://codereview.chromium.org/2094193004/diff/120001/chrome/browser/BUILD.gn#newcode1025 chrome/browser/BUILD.gn:1025: js_resource_files = [ So where does this list come ...
4 years, 5 months ago (2016-06-29 22:51:32 UTC) #43
brettw
I haven't really thought about the details of this patch, so take this to be ...
4 years, 5 months ago (2016-07-01 20:22:32 UTC) #45
aberent
On 2016/07/01 20:22:32, brettw (plz ping after 24h) wrote: > I haven't really thought about ...
4 years, 5 months ago (2016-07-05 14:59:36 UTC) #46
aberent
Responded to most comments (although missed one from thestig@, will fix on next pass). I ...
4 years, 5 months ago (2016-07-14 15:41:36 UTC) #47
Dan Beam
https://codereview.chromium.org/2094193004/diff/120001/components/resources/BUILD.gn File components/resources/BUILD.gn (right): https://codereview.chromium.org/2094193004/diff/120001/components/resources/BUILD.gn#newcode64 components/resources/BUILD.gn:64: "//ui/webui/resources/js/util.js", how are these components/ resources? https://codereview.chromium.org/2094193004/diff/120001/tools/grit/grit/format/html_inline.py File tools/grit/grit/format/html_inline.py ...
4 years, 5 months ago (2016-07-14 17:47:59 UTC) #48
Lei Zhang
https://codereview.chromium.org/2094193004/diff/120001/chrome/browser/BUILD.gn File chrome/browser/BUILD.gn (right): https://codereview.chromium.org/2094193004/diff/120001/chrome/browser/BUILD.gn#newcode1025 chrome/browser/BUILD.gn:1025: js_resource_files = [ On 2016/07/14 15:41:36, aberent wrote: > ...
4 years, 5 months ago (2016-07-15 00:13:09 UTC) #49
brettw
I still stand by my comments on the design doc that maintaining these lists twice ...
4 years, 5 months ago (2016-07-15 17:05:14 UTC) #50
Dirk Pranke
For the record, I'm staying out of this as there are enough people looking at ...
4 years, 5 months ago (2016-07-15 19:12:40 UTC) #51
aberent
On 2016/07/15 17:05:14, brettw (ping after 24h) wrote: > I still stand by my comments ...
4 years, 5 months ago (2016-07-18 14:55:21 UTC) #52
aberent
4 years, 5 months ago (2016-07-25 17:01:45 UTC) #53
On 2016/07/18 14:55:21, aberent wrote:
> On 2016/07/15 17:05:14, brettw (ping after 24h) wrote:
> > I still stand by my comments on the design doc that maintaining these lists
> > twice like this is not a good idea.
> > 
> > My suggestion, which I agree isn't perfect but which I still think is better
> > than this patch, is to have Grit filter .js files through a program you
> control
> > and run this only in official builds.
> 
> Ok, I will take another look at that option. I do, however, have a some
concerns
> about it:
> 1 - I am not sure exactly how much it will slow down official builds, but I
> think it will slow them down significantly.
> 2 - Our bots only build official builds a few times a day, so if the process
> somehow goes wrong and causes bugs or build errors (e.g. when a Javascript
file
> changes) then these will be discovered late.
> 
> An alternative CL will follow.

The alternative CL is https://codereview.chromium.org/2179033002/

Powered by Google App Engine
This is Rietveld 408576698