How to Use Google Closure's Advanced Mode Without Breaking Everything

For adamia3d I wanted to use Google Closure for minification, and I particularly wanted the maximum setting for dead code removal and function inlining. If I could make anonymous functions that I knew would get inlined, I could organize the code much better in the innermost parts of the engine (where functions are off-limits due to the performance hit of a function call in javascript). However, the maximum setting of Closure, ADVANCED_OPTIMIZATIONS, completely destroys the source for a library. Adamia3d is an open-source library, and I want every class and every property to be considered public and hackable by its users. Unfortunately Closure renames every single class and member unless you modify your source to accomodate (using class['member'] instead of class.member everywhere). Modifying my source like this is unreasonable, so I came up with a nifty hack around it.

The trick is to run Closure twice, using not-well-known command line switches "--property_map_input_file" and "--property_map_output_file". Closure supports exporting a simple text file of all the properties it renamed and how to map the short version to the long version. The hack lies in the fact that it also supports importing the same property map, originally intended for successive recompilations of the same code to have a stable mapping. All we have to do is exploit this feature with the following steps:

  • Run Closure once and generate the property map.
  • Use a simple regex to invert the property map, pointing the short versions back to the long ones.
  • Run Closure again with the inverted property map.

Here is a sample block of an Ant build.xml that runs Closure twice, and also does a hack to prevent @preserve comment blocks from getting lost in the second pass:



This article is great, hopefully useful to me and all other readers of it. Jelly Gamat QnC

google teaching

Selain tutor yang profesional, guru Les Privat Sukses Mandiri juga memberikan pelayanan konsultasi gratis selamanya. Pelayanan ini diharapkan dapat membuat siswa lebih maksimal belajar dengan cara berdiskusi bersama guru atau pihak management. Guru kami siap membantu siswa dalam proses pembelajaran setelah kegiatan les privat berlangsung. guru Les Privat ke rumah


Apakah Anda pernah memakai jasa detektif swasta untuk menyelidiki kasus perselingkuhan suami/istri atau kekasih anda? Apakah anda ingin mengetahui kenyataan yang sebenarnya ? Jasa Detektif Swasta Kami dapat membantu anda menangani kasus perselingkuhan secara profesional dan confidential. Pelayanan jasa detektif swasta terbaik di jakarta

Nice Post!

Thanks for the helpful information you have provided in this post. Regards from get-Realty Sewa Kantor

Succes !!

Nice content is easy to read :) Obat Penambah Nafsu Makan


Im understand :) Obat Peninggi Badan Anak

Ucapan terimakasih

Thank you for the information you have provided to us, his info is very helpful at all. Obat Lemak Darah Tinggi

Post new comment

The content of this field is kept private and will not be shown publicly.