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.

  1. Log into your WordPress Admin panel.
  2. Hover your mouse over “Plugins” and click “Add New.”
  3. In the “Search” box, type “Autoptimize” and click “Search Plugins.”
  4. 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.”
  5. Navigate to “Settings → Autoptimize.”
  6. Click on the “Show advanced settings” button.
  7. In the HTML section, enable “Optimize HTML Code” and “Keep HTML comments.”

  8. 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.

  9. In the “CSS Options” section, enable “Optimize CSS Code.” You can also inline your CSS so pages load faster.
    NOTE: This option is great for smaller sites, but it can actually slow down sites that have a lot of traffic.

    There is also the option to exclude certain CSS code from the plugin.

    NOTE: 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.

  10. 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 “”

    NOTE: The CDN is activated upon entering the CDN blog root directory (e.g. 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.

    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 about using this plugin effectively, feel free to start a live chat or leave a comment below.