minify messages.json files |
|||
Issue descriptionon a Pixel Chromebook, we currently ship ~440 messages.json files which add up to ~21M. these files are usually not optimally encoded: - they use \u#### escapes instead of UTF-8 - they have lots of useless whitespace converting to UTF-8 shaves off ~1.5MiB. stripping the whitespace shaves off ~3.8MiB. lets not waste space on files no one reads, especially when the source material are grd files checked in elsewhere.
,
Jun 14 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/8d3ba5c3988e897bc65c629b4172a70367c140f5 commit 8d3ba5c3988e897bc65c629b4172a70367c140f5 Author: Mike Frysinger <vapier@chromium.org> Date: Thu Jun 14 19:55:04 2018 grit: drop Unicode BOM from Chrome messages.json The BOM was added back in Dec 2012 [1] because it said the CWS wanted it in its files. However, I haven't seen this requirement in the last few years with my own extensions (uploaded plenty w/out BOMs and the localization still works), and our public docs [2] don't mention it. Drop the BOM to shrink (slightly) the files and to make it easier for other JSON parsers to handle this (as not all skip the BOM). Further, reading the CWS source directly indicates it is not required and is silently ignored. See CrxMessagesParserImpl.java:parse() which loads the JSON data through ManifestSanitizerUtil.sanitize(), and that ManifestSanitizerUtil.java:sanitize function simply does: // The incoming manifest may have a byte-order marker (0xFEFF) to denote // Unicode as its first character. Although it's not allowed in pure JSON, // we remove it here so parse just works if (content.charAt(0) == Constants.UNICODE_BYTE_ORDER_MARK) { content = content.substring(1); } return content; Url-1: https://codereview.chromium.org/11557029 Url-2: https://developer.chrome.com/extensions/i18n-messages Bug: 852585 Change-Id: I65f61eecb1147cd4c05f3a7a2295bef85023cb65 Reviewed-on: https://chromium-review.googlesource.com/1101239 Reviewed-by: agrieve <agrieve@chromium.org> Reviewed-by: Robert Flack <flackr@chromium.org> Commit-Queue: Mike Frysinger <vapier@chromium.org> Cr-Commit-Position: refs/heads/master@{#567387} [modify] https://crrev.com/8d3ba5c3988e897bc65c629b4172a70367c140f5/tools/grit/grit/tool/build.py
,
Aug 2
,
Nov 14
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/830ebc996bf084166bc3d5e1ad972f6f55270111 commit 830ebc996bf084166bc3d5e1ad972f6f55270111 Author: Mike Frysinger <vapier@chromium.org> Date: Wed Nov 14 22:28:18 2018 grit: minify json outputs This can easily save ~1k if not ~10k+ per message file. Looking at an example CrOS image today, this can add up to MB of data in the rootfs. We don't make this optional for now as it's not clear whether anyone really cares, and it's easy enough for people to pretty print the json files after the fact. Bug: 852585 Change-Id: I1d2331dfc38d404ea03facd3d0a8845f32c4f981 Reviewed-on: https://chromium-review.googlesource.com/c/1320515 Reviewed-by: Robert Flack <flackr@chromium.org> Commit-Queue: Mike Frysinger <vapier@chromium.org> Cr-Commit-Position: refs/heads/master@{#608146} [modify] https://crrev.com/830ebc996bf084166bc3d5e1ad972f6f55270111/tools/grit/grit/format/chrome_messages_json.py [modify] https://crrev.com/830ebc996bf084166bc3d5e1ad972f6f55270111/tools/grit/grit/format/chrome_messages_json_unittest.py
,
Jan 8
this is largely done. grit outputs minified messages.json by default now. |
|||
►
Sign in to add a comment |
|||
Comment 1 by bugdroid1@chromium.org
, Jun 14 2018