Autoptimize concatenates all scripts and styles, minifies and compresses them, adds expires headers, and caches them. It also moves styles to the page head and scripts to the footer. This WordPress plugin even minifies the HTML code itself, making your page extremely lightweight. Also, there are advanced options available that allow you to tailor Autoptimize to your website's specific needs.
Configuring Autoptimize from WP Admin
- Log into your WordPress Admin panel.
- Hover your mouse over “Plugins” and click “Add New.”
- In the “Search” box, type “Autoptimize” and click “Search Plugins.”
- Click “Install Now.” A prompt dialog will open and ask if you are sure you want to install the plugin. Click “OK.” After the plugin is installed, click “Activate Plugin.”
- Navigate to "Settings → Autoptimize."
- Click on the “Show advanced settings” button.
- In the HTML section, enable “Optimize HTML Code” and “Keep HTML comments.”
- In the “Javascript Options” section, enable “Optimize JavaScript Code” and “Force JavaScript in <head>.” If your .js breaks to script error, you can try enabling “Add try-catch wrapping” as well.
- In the “CSS Options” section, enable “Optimize CSS Code.” You can also inline your CSS so pages load faster.
This option is great for smaller sites, but it can actually slow down sites that have a lot of traffic.
DO NOT enable the “Generate data: URIs for images” option. This will result in a decreased number of requests when loading your website but will force images to be served through your origin instead of your CDN.
-
Enter your CDN URL in the “CDN Base URL” field, and click on the “Save Changes and Empty Cache” button. Use your CDN URL instead of "http://foo.bar.netdna-cdn.com."
The CDN is activated upon entering the CDN blog root directory (e.g. http://cdn.example.com/). If that URL is present, it will be used for all Autoptimize-generated files (i.e. aggregated CSS and JS), including 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 that this only works for images uploaded from that point onwards, not for images that were already uploaded.
Autoptimize is compatible with plugins like WP Super Cache and CDN Linker which provide a more developed rewrite functionality. Note that only one of these plugins should have CDN enabled due to possible rewrite issues.
If you have any questions or experience any issues, please reach out to the Support Team, live chat and ticket support are available 24/7.