Title: Optimizing Minimized JavaScript
Last modified: August 21, 2016

---

# Optimizing Minimized JavaScript

 *  [admintiger](https://wordpress.org/support/users/admintiger/)
 * (@admintiger)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/optimizing-minimized-javascript/)
 * A variety of JavaScript minimizers (also called compressors) are available and
   some have selectable degrees of minimization. The safest method is to simply 
   remove unnecessary white-space, line-end-characters, and comments without making
   actual script code changes, but greater degrees of minimization usually are possible
   with more aggressive methods where script code is changed in various ways to 
   make it more compact. Some aggressive methods result in code that runs in web
   browsers, but that violates one or more JavaScript language rules.
 * WordPress plugin authors often include JavaScript code that already has been 
   minimized. Where it has been minimized by a minimizer that produces valid JavaScript
   code, either the built-in PHP or external YUI JavaScript compression capabilities
   in Autoptimize generally produce valid results. The optimized code may or may
   not be smaller than the original, depending on the minimization method previously
   used, but regardless, the resulting code usually runs fine in web browsers. However,
   where plugin authors include JavaScript code that has been minimized by an aggressive
   method that produces code that violates one or more JavaScript language rules,
   Autoptimize optimization may not produce usable code.
 * As an example, I wrote a prettyPhoto WordPress plugin to meet my own needs. The
   original version of my plugin used the jquery.prettyPhoto.js 3.1.4 “production
   release” library. That version worked fine with or without Autoptimize JavaScript
   optimization. I recently upgraded my plugin to use the jquery.prettyPhoto.js 
   3.1.5 “production release” library. The upgraded plugin ran fine without Autoptimize
   optimization, but failed using either the PHP or YUI optimization options in 
   Autoptimize. The problem was found to be that the “production release” of jquery.
   prettyPhoto.js 3.1.5 has been pre-optimized by an optimizer that produces code
   that violates JavaScript language rules. The solution was to include the uncompressed“
   development version” jquery.prettyPhoto.js 3.1.5 library instead.
 * I have posted this only to explain one reason that the JavaScript code in some
   WordPress plugins cannot be successfully optimized by Autoptimize without plugin
   modification.
 * [http://wordpress.org/extend/plugins/autoptimize/](http://wordpress.org/extend/plugins/autoptimize/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/optimizing-minimized-javascript/#post-3855218)
 * Great explanation, thanks admintiger.
 * Instead of using the uncompressed dev version, you could also exclude prettyPhoto
   from being minimized in AO’s admin screen.

Viewing 1 replies (of 1 total)

The topic ‘Optimizing Minimized JavaScript’ is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/optimizing-minimized-javascript/#post-3855218)
 * Status: not a support question