Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I believe as of 1.4.2 (maybe earlier), jQuery is minified using Google Closure Compiler by default. So it's probably best to continue referencing jQuery/jQuery UI via the google CDN. However, there are still benefits to integrating the Closure compiler into your build process to combine and minify your JS files. Namely, reduced JS requests per page load and smaller data transfered in hopes of improving your client side page load performance. These are some of the challenges we encountered while integrating Closure compiler into our build process:</p> <ol> <li><p><strong>Constructing compilation command</strong> - We needed a means of invoking the compiler with all the necessary parameters in an automated manner during the build process. For us, this meant writing a console app to construct the command. If shell scripting is available in your environment, that could be an advantage.</p></li> <li><p><strong>Managing Dependencies</strong> - The Closure compiler does have the capability to automatically sort the order of the combined JS such that dependencies are preserved. In order to leverage this feature, the JS files must be annotated with <code>goog.provide\goog.require</code> to tell the compiler what the dependencies are (<a href="http://code.google.com/p/closure-compiler/wiki/ManageClosureDependencies" rel="noreferrer">--manage_closure_dependencies</a>). The compiler will also exclude any JS that isn't required (i.e. is not referenced via a <code>goog.require</code> statement) from the combined JS. Here are a few things to watch out for:</p> <ul> <li>If you want to include all of you JS files in the combined output, ensure that you include a "manifest" JS file in the compilation that only contains <code>goog.require</code> statements for each file to be included combined script (i.e. no <code>goog.provide</code> statements).</li> <li>If you aren't using the Closure Library, ensure that you are compiling using <code>SIMPLE_OPTIMIZATIONS</code> or higher. Otherwise, the compiler will not remove the <code>goog.provide/goog.require</code> statements. Alternatively, you could also define your own <code>goog.provide/goog.require</code> JS functions to avoid errors.</li> <li>Ensure there are <strong>no</strong> cyclical dependencies, or face the consequences.</li> </ul></li> <li><p><strong>Compiling a debug version of the combined script</strong> - If needed, you can compile a debug version of the combined script using the <code>--formatting PRETTY_PRINT</code> flag. This will output the equivalent script formatted with whitespaces intact for development/debugging.</p></li> </ol> <p>Although, the Closure compiler documentation can be sparse at times, it does have enough to get started for the most part and is continuously improving - so check regularly for updates, not just SO ;)</p> <p>Hope this helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload