=== Autoptimize === Contributors: futtta, turl Tags: css, html, javascript, js, optimize, speed, cache, data-uri, aggregate, minimize, minification, performance, pagespeed, booster, multisite Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/ Requires at least: 2.7 Tested up to: 3.8 Stable tag: 1.7.2 Autoptimize speeds up your website and helps you save bandwidth by aggregating and minimizing JS, CSS and HTML. == Description == Autoptimize makes optimizing your site really easy. It concatenates all scripts and styles, minifies and compresses them, adds expires headers, caches them, and moves styles to the page head, and scripts to the footer. It also minifies the HTML code itself, making your page really lightweight. There are advanced options available to enable you to tailor Autoptimize to each and every site's specific need. If you consider performance important, you really should use a caching-plugin such as e.g. [WP Super Cache](http://wordpress.org/extend/plugins/wp-super-cache/) or [HyperCache](http://wordpress.org/extend/plugins/hyper-cache/) to complement Autoptimize. == Installation == Just install form your WordPress "Plugins|Add New" screen and all will be well. Manual installation is very straightforward as well: 1. Upload the zip-file and unzip it in the /wp-content/plugins/ directory 1. Activate the plugin through the 'Plugins' menu in WordPress 1. Go to `Settings -> Autoptimize` and enable the options you want. Generally this means "Optimize HTML/ CSS/ JavaScript". == Frequently Asked Questions == = What does the plugin do to help speed up my site? = It concatenates all scripts and styles, minifies and compresses them, adds expires headers, caches them, and moves styles to the page head, and scripts to the footer. It also minifies the HTML code itself, making your page really lightweight. = Will this work with my blog? = Yes, most of the time, but there will always be exceptions. Although Autoptimize goes through great lengths to work with as many themes and plugins possible, there undoubtably are circumstances in which Autoptimize will not work to the full extent (full HTML, JS and CSS optimization). See "Troubleshooting" below for info on how to proceed if you encounter issues. = What is the use of deferring CSS? = CSS in general should go in the head of the document. Recently a.o. Google started promoting deferring non-essential CSS, while inlining those styles needed to build the page above the fold. This is especially important to render pages as quickly as possible on mobile devices. To implement this, you'll need to: * identify the essential CSS to style your average page (be strict, keep this as light a possible) * minimize that using one of the many online minimizing tools * wrap the minimized CSS between style-tags * wrap style-block between noptimize-tags (see above) * put the resulting CSS in the head of your page (should be in the header.php file of your theme) * check the option to defer CSS = How does CDN work? = Starting from version 1.7.0, CDN is activated upon entering the CDN blog root directory (e.g. http://cdn.example.net/wordpress/). If that URL is present, it will used for all Autoptimize-generated files (i.e. aggregated CSS and JS), includinng background-images in the CSS (when not using data-uri's). If you want your uploaded images to be on the CDN as well, you can change the upload_url_path in your WordPress configuration (/wp-admin/options.php) to the target CDN upload directory (e.g. http://cdn.example.net/wordpress/wp-content/uploads/). Do take into consideration this only works for images uploaded from that point onwards, not for images that already were uploaded. Thanks to [BeautyPirate for the tip](http://wordpress.org/support/topic/please-don%c2%b4t-remove-cdn?replies=15#post-4720048)! = How can I force the aggregated files to be static CSS or JS instead of PHP? = If your webserver is properly configured to handle compression (gzip or deflate) and cache expiry (expires and cache-control with sufficient cacheability), you don't need Autoptimize to handle that for you. In that case you can check the "Save aggregated script/css as static files?"-option, which will force Autoptimize to save the aggregated files as .css and .js-files (meaning no PHP is needed to serve these files). = Does Autoptimize work with BuddyPress? = Based on earlier feedback received from BuddyPress users, CSS and JS-Autoptimization do not seem to work correctly, leaving you with only HTML optimizations. This might be due to problems in Autoptimize which have already been fixed, so feel free to give it a shot anyhow. = Compatibility with WP SlimSat = There have been reports of sightings of javascript errors when using Autoptimize together with WP SlimStat. Both [Camu (WP SlimStat developer)](http://profiles.wordpress.org/coolmann/) and I have installed both plugins on test-environments and [found no proof of such incompatibility](http://wordpress.org/support/topic/dropdown-menus-dont-work-when-slimstat-is-enabled?replies=14#post-4086894). Our common conclusion is that there are rare cases in which yet another theme or plugin's JavaScript are triggering these errors. If you do encounter JavaScript-errors when you have both WP SlimStat and Autoptimize installed, add "SlimStatParams, wp-slimstat.js" in the "Exclude scripts from autoptimize:" option on the admin-page and all should be well. = Configuring & Troubleshooting Autoptimize = After having installed and activated the plugin, you'll have access to an admin page where you can to enable HTML, CSS and JavaScript optimization. According to your liking, you can start of just enabling all of them, or if you're more cautious one at a time. If your blog doesn't function normally after having turned on Autoptimize, here are some pointers to identify & solve such issues using "advanced settings": * In case your blog looks weird, i.e. when the layout gets messed up, there is problem with CSS optimization. In this case you can turn on the option "Look for styles on just head?" and see if that solves the problem. You can also force CSS not to be aggregated by wrapping it in noptimize-tags in your theme or widget or by adding filename (for external stylesheets) or string (for inline styles) to the exclude-list. * In case some functionality on your site stops working (a carroussel, a menu, the search input, ...) you're likely hitting JavaScript optimization trouble. Enable the option "Look for scripts only in head?" and/or "Force JavaScript in
?" and try again. Alternatively -for the technically savvy- you can exclude specific scripts from being treated (moved and/ or aggregated) by Autoptimize by adding a string that will match the offending Javascript or excluding it from within your template files or widgets by wrapping the code between noptimize-tags. Identifying the offending JavaScript and choosing the correct exclusion-string can be trial and error, but in the majority of cases JavaScript optimization issues can be solved this way. * If your theme uses jQuery, you can try either forcing all in head or excluding jquery(-min).js (and jQuery-plugins if needed). * If you can't get either CSS or JS optimization working, you can off course always continue using the other two optimization-techniques. * If you tried the troubleshooting tips above and you still can't get CSS and JS working at all, you can ask for support on the [WordPress Autoptimize support forum](http://wordpress.org/support/plugin/autoptimize). See below for a description of what information you should provide in your "trouble ticket" = How does "Exclude from autoptimize" work? = You can exclude both JS and CSS from being processed by Autoptimize by using the appropriate settings in the admin-screen. If you want to exclude an external file from being Autoptimized, add the filename (e.g. jquery.js). If you want to exclude inline CSS or JS, add a (unique) string that is in that block of code. = What is noptimize? = Starting with version 1.6.6 Autoptimize excludes everything inside noptimize tags, e.g.: `` You can do this in your page/ post content, in widgets and in your theme files (consider creating [a child theme](http://codex.wordpress.org/Child_Themes) to avoid your work being overwritten by theme updates). = Where can I report an error? = You can report problems on the [wordpress.org support forum](http://wordpress.org/support/plugin/autoptimize), or [contact the maintainer using this contact form](http://blog.futtta.be/contact/). = What information should I include when requesting support = * A description of the problem, including screenshots and information from your browser's Error/ debug console * URL of your blog (you can turn Autoptimize off, but should be willing to turn it briefly on to have the error visible) * your Autoptimize settings (including a description of changes you made to the configuration to try to troubleshoot yourself) * the Theme used (including the Theme's download link) * optionally plugins used (if you suspect one or more plugins are raising havoc) == Changelog == = 1.7.2 = * improvement: extra checks in CSS @import-handling + move import rules to top of CSS if not imported successfully, based a.o. on bug reports [by ozum](http://wordpress.org/support/topic/zero-lenght-file-with-css-optimization) and by [Peter Stolwijk](http://wordpress.org/support/topic/cant-activate-plugin-22?replies=13#post-4891377) * improvement: check if JS and CSS minifier classes exist and only load if they don't to avoid possible conflicts with other themes or plugins that already loaded minifiers * tested and approved for WordPress 3.8 (beta1) = 1.7.1 = * New: support for mapped domains as suggested by [Michael for tiremoni.com](http://tiremoni.com/) * Added an .htaccess to wp-content/cache/autoptimize to overwrite other caching directives (fixing a problem with WP Super Cache's .htaccess really, [as reported](http://wordpress.org/support/topic/expiresmax-age-compatibility-with-supercache) by [Hugh of www.unitedworldschools.org](http://www.unitedworldschools.org/)) * bugfix: Autoptimize broke data:uri's in CSS in some cases as reported by [Joseph from blog-it-solutions.de](http://www.blog-it-solutions.de/) * bugfix: avoid PHP notice if CSS exclusion list is empty * moved "do not donate"-image into plugin = 1.7.0 = * New: exclude CSS * New: defer CSS * Updated minimizing components (JSMin & YUI PHP CSSMin) * Updated admin-page, hiding advanced configuration options * Updated CDN-support for added simplicity (code & UI-wise), including changing background image url in CSS * Updated/ new translations provided for [French: wordpress-hebergement.fr](http://www.wordpress-hebergement.fr/), [Persian: Hamed Irani](http://basics.ir/), [Swedish: Jonathan Sulo](http://sulo.se/), [German: blog-it-solutions.de](http://www.blog-it-solutions.de/) and Dutch * Removed support for YUI * Flush HTML caching plugin's cache when flushing Autoptimize's one * fix for BOM marker in CSS-files [as seen in Frontier theme](http://wordpress.org/support/topic/sidebar-problem-42), kudo's to [Download Converter](http://convertertoolz.com/) for reporting! * fix for [protocol-less 3rd party scripts disappearing](http://wordpress.org/support/topic/javascript-optimize-breaks-twentythirteen-mobile-menu), thanks for reporting p33t3r! * fix for stylesheets without type="text/css" not being autoptimized as reported by [renzo](http://cocobeanproductions.com/) * tested with WordPress 3.7 beta2 (admin-bar.min.js added to automatically excluded scripts) = 1.6.6 = * New: disable autoptimizatoin by putting part of your HTML, JS or CSS in between noptimize-tags, e.g.; `` * Added extra check to prevent plugin-files being called outside of WordPress as suggested in [this good article on security](http://mikejolley.com/2013/08/keeping-your-shit-secure-whilst-developing-for-wordpress/). * Added small notice to be displayed after installation/ activation to ask user to configure the plugin as well. * Added Persian translation, thanks to [Hamed T.](http://basics.ir/) = 1.6.5 = * new javascript-debug option to force the aggregated javascript file in the head-section of the HTML instead of at the bottom * YUI compression & CDN are now deprecated functionality that will be removed in 1.7.0 = 1.6.4 = * fix for PHP notice about mfunc_functions * fix for strpos warnings due to empty values from the "Exclude scripts from autoptimize" configuration as [reported by CandleFOREX](http://wordpress.org/support/topic/empty-needle-warning) * fix for broken feeds as [reported by Dinata and talgalili](http://wordpress.org/support/topic/feed-issue-5) = 1.6.3 = * fix for IE-hacks with javascript inside, causing javascript breakage (as seen in Sampression theme) as reported by [Takahiro of hiskip.com](http://www.hiskip.com/wp/) * fix for escaping problem of imported css causing css breakage (as seen in Sampression theme) as reported by Takahiro as well * fix to parse imports with syntax @import 'custom.css' not being parsed (as seen in Arras theme), again as reported by Takahiro * fix for complex media types in media-attribute [as reported by jvwisssen](http://wordpress.org/support/topic/autoptimize-and-media-queries) * fix for disappearing background-images that were already datauri's [as reported by will.blaschko](http://wordpress.org/support/topic/data-uris) * fix not to strip out comments in HTML needed by WP Super Cache or W3 Total Cache (e.g. mfunc) * added check to clean cache on upgrade * updated FAQ in readme with information on troubleshooting and support * tested with WordPress 3.6 beta = 1.6.2 = * Yet another emergency bugfix I'm afraid: apache_request_headers (again in config/delayed.php) is only available on ... Apache (duh), breaking non-Apache systems such as ngnix, Lighttpd and MS IIS badly. Reported by multiple users, thanks all! = 1.6.1 = * fixed stupid typo in config/delayed.php which broke things badly (april fools-wise); strpos instead of str_pos as reported by Takahiro. = 1.6.0 = * You can now specify scripts that should not be Autoptimized in the admin page. Just add the names (or part of the path) of the scripts in a comma-seperated list and that JavaScript-file will remain untouched by Autoptimize. * Added support for ETag and LastModified (essentially for a better pagespeed score, as the files are explicitely cacheable for 1 year) * Autoptimizing for logged in users is enabled again * Autoptimize now creates an index.html in wp-content/cache/autoptimize to prevent snooping (as [proposed by Chris](http://blog.futtta.be/2013/01/07/adopting-an-oss-orphan-autoptimize/#li-comment-36292)) * bugfix: removed all deprecated functions ([reported by Hypolythe](http://wordpress.org/support/topic/many-deprecated-errors) and diff by Heiko Adams, thanks guys!) * bugfix for HTTPS-problem as [reported by dbs121](http://wordpress.org/support/topic/woocommerce-autoptimizer-https-issue) * bugfix for breakage with unusual WordPress directory layout as reported by [Josef from blog-it-solutions.de](http://www.blog-it-solutions.de/). = 1.5.1 = * bugfix: add CSS before opening title-tag instead of after closing title, to avoid CSS being loaded in wrong order, as reported by [fotofashion](http://fotoandfashion.de/) and [blogitsolutions](http://www.blog-it-solutions.de) (thanks guys) = 1.5 = * first bugfix release by [futtta](http://blog.futtta.be/2013/01/07/adopting-an-oss-orphan-autoptimize/), thanks for a great plugin Turl! * misc bug fixes, a.o. support for Twenty Twelve theme, admin bar problem in WP3.5, data-uri breaking CSS file naming = 1.4 = * Add support for inline style tags with CSS media * Fix Wordpress top bar = 1.3 = * Add workaround for TinyMCEComments * Add workaround for asynchronous Google Analytics = 1.2 = * Add workaround for Chitika ads. * Add workaround for LinkWithin widget. * Belorussian translation = 1.1 = * Add workarounds for amazon and fastclick * Add workaround for Comment Form Quicktags * Fix issue with Vipers Video Quicktags * Fix a bug in where some scripts that shouldn't be moved were moved * Fix a bug in where the config page wouldn't appear * Fix @import handling * Implement an option to disable js/css gzipping * Implement CDN functionality * Implement data: URI generation for images * Support YUI CSS/JS Compressor * Performance increases * Handle WP Super Cache's cache files better * Update translations = 1.0 = * Add workaround for whos.among.us * Support preserving HTML Comments. * Implement "delayed cache compression" * French translation * Update Spanish translation = 0.9 = * Add workaround for networkedblogs. * Add workarounds for histats and statscounter * Add workaround for smowtion and infolinks. * Add workaround for Featured Content Gallery * Simplified Chinese translation * Update Spanish Translation * Modify the cache system so it uses wp-content/cache/ * Add a clear cache button = 0.8 = * Add workaround for Vipers Video Quicktags * Support tags without media. * Take even more precautions so we don't break urls in CSS * Support adding try-catch wrappings to JavaScript code * Add workaround for Wordpress.com Stats * Fix a bug in where the tags wouldn't move * Update translation template * Update Spanish translation = 0.7 = * Add fix for DISQUS Comment System. = 0.6 = * Add workaround for mybloglog, blogcatalog, tweetmeme and Google CSE = 0.5 = * Support localization * Fix the move and don't move system (again) * Improve url detection in CSS * Support looking for scripts and styles on just the header * Fix an issue with data: uris getting modified * Spanish translation = 0.4 = * Write plugin description in English * Set default config to everything off * Add link from plugins page to options page * Fix problems with scripts that shouldn't be moved and were moved all the same = 0.3 = * Disable CSS media on @imports - caused an infinite loop = 0.2 = * Support CSS media * Fix an issue in the IE Hacks preservation mechanism * Fix an issue with some urls getting broken in CSS = 0.1 = * First released version.