Autoptimize

描述

Autoptimize makes optimizing your site really easy. It can aggregate, minify and cache scripts and styles, injects CSS in the page head by default but can also inline critical CSS and defer the aggregated full CSS, moves and defers scripts to the footer and minifies HTML. You can optimize and lazy-load images (with support for WebP and AVIF formats), optimize Google Fonts, async non-aggregated JavaScript, remove WordPress core emoji cruft and more. As such it can improve your site’s performance even when already on HTTP/2! There is extensive API available to enable you to tailor Autoptimize to each and every site’s specific needs.
If you think performance indeed is important, you should at least consider one of the many free page caching plugins (e.g. Speed Booster pack or KeyCDN’s Cache Enabler) to complement Autoptimize or even consider Autoptimize Pro which not only has page caching but also image optimization, CDN, critical CSS and more!

Autoptimize Pro
Autoptimize Pro is a premium Power-Up, adding image optimization, CDN, page caching, automatic critical CSS rules and extra “booster” options, all in one handy subscription to make your site even faster!!

Premium Support
We provide great Premium Support and Web Performance Optimization services with Accelera, check out our offering on https://accelerawp.com/!

(Speed-surfing image under creative commons by LL Twistiti)

安装

只需从您的 WordPress “插件 > 添加新插件” 屏幕安装, 一切都方便的。手动安装也非常简单:

  1. 上传 zip 文件并将其解压缩到 /wp-content/plugins/ 目录中
  2. 通过 WordPress 的 “插件” 菜单激活插件
  3. 转到 设置 > Autoptimize 并启用你想要的选项。通常这意味着 “优化 HTML/ CSS/ JavaScript”。

常见问题

插件怎么帮助加快我的网站?

It minifies all scripts and styles and configures your webserver to compresses them with good expires headers. JavaScript be default will be made non-render-blocking and CSS can be too by adding critical CSS. You can configure it to combine (aggregate) CSS & JS-files, in which case styles are moved to the page head, and scripts to the footer. It also minifies the HTML code and can also optimize images and Google Fonts, making your page really lightweight.

但是我使用的是 HTTP/2, 所以我不需要 Autoptimize?

HTTP/2 无疑是向前迈出的重要一步, 通过使用同一连接执行多个并发请求, 可以大大减少来自同一服务器的多个请求的影响。话虽如此, 串联 CSS/JS 仍然很有意义, 正如 这篇 css-tricks.com 文章 和这位 来自一位 Ebay 工程师的博文。结论; 配置, 测试, 重新配置, 重新测试, 调整并查看在您的上下文中最有效的方法。也许只是 HTTP/2, 也许是 HTTP/2 + 聚合和最小化, 也许是 HTTP/2 + 最小化 (AO 也可以做到, 只需取消选中 “聚合 JS 文件” 和/或 “聚合 CSS 文件” 选项)。Autoptimize 可以做更多的工作, 当然 “不仅是” 优化您的 JS& CSS 😉

这可与我的博客一起工作吗?

Although Autoptimize comes without any warranties, it will in general work flawlessly if you configure it correctly. See “Troubleshooting” below for info on how to configure in case of problems. If you want you can test Autoptimize on a new free dummy site, courtesy of tastewp.com.

Why is jquery.min.js not optimized when aggregating JavaScript?

从 AO 2.1 开始, WordPress 核心的 jquery.min.js 并未进行优化, 原因很简单, 因为许多流行的插件都注入了未聚合的内联 JS(由于内联 JS 中的独特代码可能存在缓存大小问题), 这依赖于 jquery 可用, 因此排除 jquery.min.js 可确保大多数网站开箱即用。如果您还想优化 jquery, 则可以将其从 JS 优化排除列表中删除(您可能还必须启用 “也聚合内联 JS” 或切换为 “强制 JS 执行”)。

为什么自动优化的 JS 阻塞渲染?

当聚合 JavaSCript 并勾选“force in head”选项时,或者当不聚合且不延迟时,会发生这种情况。 考虑更改设置。

为什么自动优化的 CSS 仍然被称为阻塞渲染?

使用默认的 Autoptimize 配置时, CSS 链接在头部, 这是一个安全的默认设置, 但 Google PageSpeed Insights 会抱怨。您也可以查看”内联所有CSS”(简单)或”内联和延迟CSS”(更好), 这在本常见问题解答中也有介绍。

“内嵌和推迟CSS” 的用法是什么?

一般而言, CSS 应该放在文档的开头。最近, 谷歌(Google)开始推广推迟不必要的 CSS, 同时内嵌在页面上方构建页面所需的那些样式。这对于在移动设备上尽快渲染页面尤为重要。从 Autoptimize 1.9.0 开始, 这很容易。选择 “内联并延迟CSS”, 将 “折叠 CSS 上方” 块粘贴到输入字段(文本区域)中, 您就可以开始了!

但是, 如何找出”折叠CSS之上”是什么?

对于这种情况, 没有简单的解决方案, 因为 “折叠上方” 取决于折叠位置, 而折叠取决于屏幕尺寸。但是, 有一些可用的工具试图识别 “首屈一指” 的含义。此工具列表是一个很好的起点。Sitelocity Critical CSS 生成器乔纳斯·奥尔森(Jonas Ohlsson)的criticalpathcssgenerator 是很好的基本解决方案, 并且 http://criticalcss.com/ 是同一位 Jonas Ohlsson 的高级解决方案。另外, 此书签(仅适用于Chrome)也可能会有所帮助。

还是应该内联所有 CSS?

简短的答案:可能不会。尽管内联所有 CSS 将使 CSS 成为非阻塞渲染, 但这将导致您的基本 HTML 页面变得更大, 从而需要更多的 “往返时间”。此外, 当考虑到在浏览会话中请求多个页面时, 每次都会发送内联 CSS, 而当没有内联时, 它将从缓存中提供。最终, 内联的 CSS 将把 HTML 中的元标记向下推送至 Facebook 或 Whatsapp 可能不再寻找它的位置, 从而破坏了 在这些平台上共享时的缩略图。

我的缓存越来越大了, Autoptimize 不会清除缓存吗?

Autoptimize 没有适当的缓存清除机制, 因为这可能会删除优化的 CSS/JS, 而 CSS/JS 在其他缓存中仍被引用, 这会破坏您的站点。此外, 高速缓存的增长表明 您应该避免其他问题

相反, 您可以通过以下任一方法将缓存大小保持在可接受的水平:

  • 停用 “聚集内联JS” 和/或 “聚集内联CSS” 选项
  • 不包括基于每个页面(或每个页面加载)变化的 JS 变量(有时是 CSS 选择器)。您可以阅读 在此博客文章中

尽管有上述反对意见, 还是有第三方解决方案可以自动清除 AO 缓存, 例如使用 此代码此插件, 但是由于上述原因, 仅当您真正知道自己在做什么时才使用这些解决方案。

“清除缓存” 似乎不工作?

在管理工具栏中点击自动优化下拉菜单中的 “删除缓存” 链接时, 您可能会收到 “您的缓存可能未被成功清除”。在这种情况下, 请转到 “自动优化设置” 页面, 然后单击 “保存更改并清除缓存” 按钮。

此外, 请不要担心您的缓存是否永远不会降到0个文件/ 0KB, 因为 Autoptimize (从2.2版开始)将在清除缓存后立即自动预加载缓存, 以加快进一步缩小的速度。

当我清除Autoptimize缓存时, 我的网站看起来很糟糕!

清除 AO 的缓存时, 任何页面缓存都不应包含引用已删除的优化 CSS/JS 的页面 (HTML)。尽管为此目的在 Autoptimize 和某些页面缓存之间进行了集成, 但是这种集成不能覆盖100%的设置, 因此您可能需要手动清除页面缓存。

我还能使用 Cloudflare 的 Rocket Loader 吗?

Cloudflare Rocket Loader 是一种非常先进的侵入性方法, 用于使 JavaScript 不渲染阻塞, Cloudflare 仍将其视为 Beta。有时 Autoptimize 和Rocket Loader 可以一起工作, 有时却不能。最好的方法是禁用 Rocket Loader, 然后配置 Autoptimize 并重新启用 Rocket Loader (如果您认为有帮助), 然后测试一切是否仍然有效。

目前(2017年6月), 似乎 RocketLoader 可能会破坏 AO 的 “内联并延迟CSS”, 这是基于 Filamentgroup 的 loadCSS, 导致延迟的 CSS 无法加载。

我尝试过 Autoptimize, 但我的 Google Pagespeed 得分几乎没有提高

Autoptimize 不是一个简单的 “解决我的页面速度问题” 插件。它仅聚合并最小化(本地) JS 与 CSS 和图片, 并提供了一些不错的附加功能, 例如删除 Google 字体并推迟 CSS 的加载。这样, Autoptimize 将使您可以提高性能(以秒为单位的加载时间), 也可能会帮助您解决一些特定的 Pagespeed 警告。如果您想进一步改进, 则可能还需要研究例如 页面缓存和您的网络服务器配置, 这将提高真实性能(再次, 例如由 https://webpagetest.org 衡量的加载时间)和”性能最佳实践”页面速度评级。

我能用 API 做什么?

很多; 您可以使用一些过滤器来有条件地禁用每个请求的自动优化, 更改 CSS 和 JS 排除项, 更改要在 CSS 中内联的CSS背景图像的限制, 定义哪些JS文件在聚合后移动一种, 更改聚集的JS脚本标签上的defer属性, … 在 autoptimize_helper.php_example 和此 FAQ 中有一些过滤器的示例。

CDN 如何工作?

从 1.7.0 版开始, 进入 CDN 博客根目录 (例如 http://cdn.example.net/wordpress/)后, 就会激活 CDN。如果存在该网址, 它将用于所有 Autoptimize 生成的文件(即, 聚合的 CSS 和JS), 包括 CSS 中的背景图片(不使用 data-uri 时)。

如果您还希望将上传的图像也放在 CDN 上, 则可以将 WordPress 配置(/wp-admin/options.php)中的 upload_url_path 更改为目标 CDN 上传目录(例如 http://cdn.example.net/wordpress/wp-content/uploads/)。请注意, 这仅适用于从那时起上传的图像, 不适用于已经上传的图像。感谢 BeautyPirate 的提示!

为什么我的字体不能放在 CDN 上呢?

Autoptimize 支持此功能, 但是默认情况下未启用它, 因为 非本地字体可能需要一些额外的配置。但是, 如果您有适当的跨域请求策略, 则可以通过钩子 API 告诉 Autoptimize 将字体放在 CDN 上, 以这种方式将 autoptimize_filter_css_fonts_cdn 设置为 true;

add_filter( 'autoptimize_filter_css_fonts_cdn', '__return_true' );

我正在使用 Cloudflare, 应该以 CDN 根目录输入什么

没什么, 在 Cloudflare 上时, 您自动优化的 CSS/JS 自动在 Cloudflare 的 CDN 上。

我如何强制聚合文件是静态 CSS 或 JS 而不是 PHP?

如果您的网络服务器已正确配置为处理压缩(gzip或deflate)和缓存过期(具有足够的可缓存性的过期和缓存控制), 则不需要 Autoptimize 来为您处理。在这种情况下, 您可以选中 “将聚合的脚本/css保存为静态文件吗?” 选项, 这将强制 Autoptimize 将聚合的文件另存为 .css 和 .js 文件(这意味着不需要PHP即可提供这些文件)。自 Autoptimize 1.8 起, 此设置为默认设置。

“排除优化” 如何工作?

通过将 “标识符” 添加到以逗号分隔的排除列表中, CSS 和 JS 优化都可以跳过代码的聚集和最小化。可以使用这种方式确定要使用的确切标识符字符串:

  • 如果要排除特定文件, 例如 wp-content/plugins/funkyplugin/css/style.css, 则可以简单地排除 “funkyplugin/css/style.css”
  • 如果要排除特定插件的所有文件, 例如 wp-content/plugins/funkyplugin/js/*, 则可以排除例如 “funkyplugin/js/” 或 “plugins/funkyplugin”
  • 如果要排除内联代码, 则必须在该代码块中找到一个特定的唯一字符串, 并将其添加到排除列表中。示例: 要排除 <script>funky_data='Won\'t you take me to, Funky Town'</script> , 标识符为 “funky_data”。

Troubleshooting Autoptimize

在 https://blog.futtta.be/2022/05/05/what-to-do-when-autoptimize-breaks-your-site/ 查看故障排除说明

我排除了文件, 但它们仍然被自动优化?

如果文件名指示文件尚未缩小, 则 AO 缩小排除的 JS/CSS。从 AO 2.5 开始, 您可以在 misc 下的 “JS, CSS 和 HTML” 选项卡上禁用此功能。通过取消选中 “最小化排除的文件” 来选择选项。

需要帮助, 启用 Autoptimize 后, 我有一个空白页面或内部服务器错误!!

确保您没有同时运行其他 HTML, CSS 或 JS缩小插件 (BWP minify, WP minify, …) 同时也没有运行该功能或禁用了页面缓存插件(W3 Total Cache, WP Fastest Cache……)。尝试仅启用CSS或仅启用JS优化, 以查看是哪一种导致服务器错误, 然后按照常规的故障排除步骤查找解决方法。

但是我仍然有空白的自动优化的CSS或JS文件!

如果您运行的是 Apache, 则 Autoptimize 编写的 .htaccess 文件在某些情况下可能会与 Apache 配置的 AllowOverrides 设置发生冲突(某些 Ubuntu 安装的默认配置就是这种情况), 这会导致出现”内部服务器错误 “自动优化CSS和JS文件。可以通过 将 AllowOverrides 设置为 All 来解决。

无法登录域映射的多站点

域映射的多站点需要在另一个 WordPress 动作中初始化 Autoptimize, 将这行代码添加到 wp-config.php 中以使其挂接到 setup_theme 中, 例如:

define( 'AUTOPTIMIZE_SETUP_INITHOOK', 'setup_theme' );

我没有任何错误, 但是我的页面根本没有优化?

在实际优化之前, Autoptimize 会进行大量检查。如果满足以下条件之一, 则不会优化您的页面:

  • 当在定制器中
  • 如果没有开头的 <html 标记
  • 如果响应中有 <xsl:stylesheet(指示输出不是HTML而是XML)
  • 响应中是否有 < html amp (因为 AMP 页面已经优化)
  • 如果输出是 RSS 提要 (is_feed()函数)
  • 如果输出是 WordPress 管理页面 (is_admin()函数)
  • 如果请求该页面并在URL后面附加 ?ao_noptimize=1
  • 如果代码挂接到 Autoptimize 以禁用优化(请参阅Visual Composer上的主题)
  • 如果其他插件以不兼容的方式使用输出缓冲区(有选择地禁用其他插件以识别罪魁祸首)

Visual Composer, Beaver 生成器和类似的页面生成器解决方案被破坏了!!

禁用对登录用户启用自动优化功能的选项, 并疯狂地拖放;-)

需要帮助, 我的店铺结帐/付款不起作用了!!

禁用用于优化购物车/结帐页面的选项(适用于WooCommerce, Easy Digital Downloads和WP eCommerce)。

Revolution Slider 坏了!

确保js/jquery/jquery.min.js在JS优化排除项的逗号分隔列表中(默认配置中未包括)。

我收到 “未定义 jQuery” 错误

在这种情况下, 您需要取消加载需要加载 jQuery 的非聚合 JavaScript, 因此您必须将js/jquery/jquery.min.js添加到以逗号分隔的 JS 优化排除项列表中。

我使用 NextGen Galleries, 很多 JS 没有汇总/缩小?

NextGen Galleries 做一些漂亮的事情来添加 JavaScript。为了使 Autoptimize 能够进行汇总,您可以使用以下代码段add_filter('run_ngg_resource_manager','__return_false'); 禁用 Nextgen Gallery 的资源管理,也可以告诉 Autoptimize 进行更早的初始化, 通过将其添加到您的 wp-config.php 中:define(" AUTOPTIMIZE_INIT_EARLIER"," true");

什么是 noptimize?

从版本1.6.6开始, Autoptimize 排除了noptimize 标签内的所有内容, 例如:
<!--noptimize--><script>alert(‘this will not get autoptimized’);</script><!--/noptimize-->

您可以在页面/文章内容, 小工具和主题文件中执行此操作(考虑创建 子主题, 以避免主题更新会覆盖您的工作)。

我可以更改缓存的自动优化文件的目录和文件名吗?

是的, 如果您要从 /wp-content/resources/aggregated_12345.css 提供文件, 而不是从默认的 /wp-content/cache/autoptimize/autoptimize_12345.css 提供文件, 请将其添加到 wp-config.php:

define('AUTOPTIMIZE_CACHE_CHILD_DIR','/resources/');
define('AUTOPTIMIZE_CACHEFILE_PREFIX','aggregated_');

这可以用于非默认的 WP_CONTENT_URL 吗?

不可以, Autoptimize 不支持开箱即用的非默认 WP_CONTENT_URL, 但这可以通过将几行代码连接到 Autoptimize 的 API 中来完成。

生成的 JS/ CSS 是否可以预先压缩?

是的, 但是默认情况下处于关闭状态。您可以通过将 “true” 传递给 “autoptimize_filter_cache_create_static_gzip” 来启用此功能。显然, 您仍然必须将网络服务器配置为使用这些文件, 而不是使用非压缩文件, 以避免动态压缩的开销。

什么 “删除表情符号”呢?

Autoptimize 2.3 中的此新选项删除了 WordPress 核心添加的内联 CSS, 内联 JS 和链接的 JS 文件。因此, 这可能会对您网站的性能产生较小的积极影响。

“删除查询字符串” 有用吗?

尽管某些在线性能评估工具会将 “静态文件的查询字符串” 作为性能问题来挑选出来, 但是通常这些影响几乎不存在。像这样 Autoptimize(自2.3版开始)允许您删除查询字符串(或更准确地说是 “ver” 参数), 但是勾选 “从静态资源中删除查询字符串” 对您网站的性能几乎是毫秒级的影响。

我应该(如何)优化 Google 字体?

Google 字体通常由 “阻塞渲染” 链接的 CSS 文件加载。如果您有使用 Google 字体的主题和插件, 则最终可能会得到多个这样的 CSS 文件。Autoptimize (自2.3版开始)现在使您可以通过一起删除 Google 字体或优化它们的加载方式来减轻它们的影响。有两种优化口味; 第一个是 “组合和链接”, 它将所有对 Google 字体的请求替换为一个请求, 该请求仍然会阻止渲染, 但允许立即加载字体(这意味着您不会看到字体在页面被更改时正在加载)。替代方法是 “合并并加载异步”, 它使用 JavaScript 以非渲染阻止的方式加载字体, 但可能会导致 “未样式化文本闪烁”。

我要怎样使用 “预连接”

预连接是一种高级功能, 可以指示浏览器 (如果支持) 建立与特定域的连接, 即使不是立即需要连接也是如此。例如, 这可用于减轻第三方资源对 HTTPS 的影响(因为 DNS 请求, TCP 连接和 SSL/TLS 协商较早执行)。谨慎使用, 因为预连接到太多域可能适得其反。

什么时候我不可以异步 JS?

未自动优化的 JavaScript 文件(因为它们被排除在外或因为它们在其他地方托管)通常会渲染阻塞。通过在逗号分隔的 “异步JS” 字段中添加它们, Autoptimize 将添加异步标志, 从而导致浏览器异步加载这些文件(即, 非渲染阻止)。但是, 这可能会破坏您的站点(页面), 例如, 如果异步 “js/jquery/jquery.min.js”, 则很可能会收到 “未定义jQuery” 错误。小心使用。

图像优化如何工作?

启用图像优化后, Autoptimize 将在图像标签和从您自己的域加载的 CSS 文件中查找 png, gif, jpeg(.jpg) 文件, 并将这些文件的 src(源)更改为 ShortPixel CDN。重要提示:这仅适用于公开可用的图像, 否则图像优化代理将无法获取图像来对其进行优化, 因此防火墙或代理或密码保护甚至热链接防护都可能会中断图像优化。

我可以对我的局域网/受保护的站点使用图像优化吗?

没有; 图像优化取决于外部图像优化服务从您的站点获取原始图像, 对其进行优化并将其保存在 CDN 上的能力。如果匿名访问者无法下载图像(由于防火墙/代理/密码保护/热链接保护), 则图像优化将无法进行。

在哪里可以获得有关图像优化的更多信息?

看看Shortpixel 的常见问题

我可以禁用 AO 来监听页面缓存清除吗?

从 AO 2.4 开始, AO 会 “监听” 页面缓存清除以清除其自身的缓存。您可以使用此过滤器禁用此行为;

add_filter('autoptimize_filter_main_hookpagecachepurge','__return_false');

优化后, 一些非 ASCII 字符会丢失

默认情况下, AO 使用非多字节安全字符串方法, 但如果您的 PHP 具有 mbstring 扩展名, 则可以使用此过滤器启用多字节安全字符串函数;

add_filter('autoptimize_filter_main_use_mbstring', '__return_true');

我无法使用 Critical CSS

在此处查看 有关(传统)”启动”的常见问题解答,此信息将在以后集成到该常见问题解答中。

使用 Autoptimize 2.7 时, 我仍需要 Critical CSS 启动吗?

不,不再需要 Critical CSS power-up,所有功能(以及许多修复/改进)现在都是 Autoptimize 的一部分。

“启用404后备广告” 有什么作用? 我为什么需要这个?

Autoptimize 缓存聚合和优化的 CSS/JS 以及指向这些缓存文件的链接都存储在 HTML 中, 这些内容将存储在页面缓存中(可以是插件, 可以在主机级别, 可以在第3方使用, 在 Google 中缓存, 在浏览器中)。如果页面缓存中有HTML链接到同时已被删除的 Autoptimized CSS/JS(清除了缓存), 则缓存中的页面将无法按预期方式工作, 因为找不到 CSS 或 JS (404错误)。

此设置旨在通过提供 “备用” CSS 或 JS 来防止事情中断。后备文件是清空缓存后创建的第一个 Autoptimized CSS 和 JS文件的副本,因此将基于主页。这意味着 CSS/JS 迁移不会在其他页面上应用100%,但是至少会减少丢失 CSS/JS 的影响(通常会大大减少)。

启用该选项后, Autoptimize 会向 .htaccess 中添加一个 ErrorDocument 404(由 Apache 使用), 并且还将与 WordPress 核心 template_redirect 挂钩, 以捕获 WordPress 处理的 404。当使用 NGINX 时, 下面的内容应该可以工作(我不是NGINX专家, 但确实可以工作);

location ~* /wp-content/cache/autoptimize/.*\.(js|css)$ {
    try_files $uri $uri/ /wp-content/autoptimize_404_handler.php;
}

And this a nice alternative approach (provided by fboylovesyou);

location ~* /wp-content/cache/autoptimize/.*\.(css)$ {
    try_files $uri $uri/ /wp-content/cache/autoptimize/css/autoptimize_fallback.css;
}
location ~* /wp-content/cache/autoptimize/.*\.(js)$ {
    try_files $uri $uri/ /wp-content/cache/autoptimize/js/autoptimize_fallback.js;
}

Autoptimize 中使用了哪些开源软件/项目?

以下伟大的开源项目以某种形式在 Autoptimize 中使用:

我在哪里可以获得帮助?

您可以在 wordpress.org 支持论坛 上获得帮助。如果您100%确信使用 Autoptimize 配置无法解决您的问题,并且实际上发现了代码中的错误,则可以 在 GitHub 上创建问题。如果您正在寻找高级支持,请查看我们的 Autoptimize Pro 支持和网络性能优化服务

我要退出, 该如何删除自动优化?

  • 禁用插件(这将删除选项和缓存)
  • 移除插件
  • 清除所有可能仍具有引用自动优化 CSS/JS 的页面的缓存(例如, 页面缓存插件(例如WP Super Cache)的页面)

我如何帮助/贡献?

只需 在 Github上分叉 Autoptimize 并进行编码即可!

评价

2024年2月19日 1 回复
With Autoptimize the performance of my websites improves and in case of problems their assistance is very helpful.
2024年2月12日 1 回复
Not that much to add. It's simply the best (free) plugin to optimize and speed up your website. It works well and has a lot of feature to go deeper and optimize even more. Plus: the support here on the wordpress.org forum is one of the best out here. Keep up the good work!
2024年2月2日 1 回复
I was having a plugin conflict because of an unrelated plugin and the Autoptimize plugin author was extremely quick to reply to my support thread and help me work out an extensive series of steps to best optimize the website and work around this conflict. I deeply appreciated this selfless support that went above and beyond any initial expectations. I am happy to have Autoptimize working and speeding things up!
阅读所有1,402条评价

贡献者及开发者

“Autoptimize” 是开源软件。 以下人员对此插件做出了贡献。

贡献者

“Autoptimize”插件已被翻译至32种本地话语言。 感谢所有译者为本插件所做的贡献。

将“Autoptimize”翻译成您的语言。

对开发感兴趣吗?

您可以浏览代码,查看SVN仓库,或通过RSS订阅开发日志

更新日志

3.1.11

3.1.10

  • improvement: with “don’t aggregate but defer” and “also defer inline JS” on, also defer JS that had the async flag to avoid the (previously) asynced JS from executing before the inline JS has ran.
  • improvement: show option to disable the default on “compatibility logic”.
  • fix for regression in 3.1.9 which caused JetPack Image optimization not working even if image optimization was off in AO.
  • API: some extra hooks in critical CSS to enable others (and AOPro) to act on changes in critical CSS rules
  • some other minor changes/ improvements/ filters, see the GitHub commit log.

3.1.9

  • improvement: activate JS, CSS & HTML optimization upon plugin activation (hat tip to Adam Silverstein (developer relations engineer at Google))
  • improvement: also defer asynced JS (to ensure execution order remains intact; asynced JS should not execute before deferred inline JS which it might depend upon)
  • improvement: exclude images from being lazyloaded if they have fetchpriority attribute set to high (as done by WordPress core since 6.3)
  • bugfix: disable spellcheck on CSS textarea’s (above the fold CSS/ critical CSS) which in some cases caused browser issues
  • add tab to explain Autoptimize Pro.
  • confirmed working with WordPress 6.4 (beta 3)
  • some other minor changes/ improvements/ filters, see the GitHub commit log.

3.1.8.1

  • urgent fix for PHP error, sorry about that!

3.1.8

  • Images: improve optmization logic for background images
  • Critical CSS: don’t trigger custom_post rule if not is_singular + adding debug logging for rule selection
  • some other minor changes/ improvements/ filters, see the GitHub commit log.

3.1.7

  • security: improve validation (import) and sanitization (output) of critical CSS rules, to fix a medium severity Admin+ Stored Cross-Site Scripting vulnerability as reported by WP Scan Security.

3.1.6

  • CSS: removing trailing slashes in <link tags for more W3 HTML validation love
  • Extra: also dequeue WooCommerce block CSS if “remove WordPress block CSS” option is active
  • imgopt: also act on non-aggregated inline CSS
  • imgopt: added logic to warn users if Shortpixel can’t reach their site
  • backend: AO toolbar JS/ CSS is finally minified as well.
  • explicitly disable optimization of login pages
  • some other minor changes/ improvements/ filters, see the GitHub commit log.

3.1.5

  • improvements to JSMin by Robert Ehrenleitner (big thanks Robert!).
  • do not consider jquery.js as minified any more (WordPress now uses jquery.min.js by default and jquery.js is the unminified version).
  • fix for “undefined array key” PHP errors in autoptimizeCriticalCSSCron.php
  • some other minor changes/ improvements/ filters, see the GitHub commit log.

3.1.4

  • Improvement: when all CSS is inlined, try doing so after SEO meta-tags (just before ld+json script tag which most SEO plugins add as last item on their list).
  • Img opt: also optimize images set in data-background and data-retina attributes (+ filter to easily add other attributes)
  • CSS opt: filter to enable AO to skip minification of calc formulas in CSS (as the CSS minifier on rare occasions breaks those)
  • Multiple other filters added
  • Some other minor changes/ improvements/ filters, see the GitHub commit log.

3.1.3

  • Multiple fixes for metabox LCP image preloads (thanks Kishorchand for notifying & providing a staging environment to debug on).
  • Fix in revslider compatibility (hat tip Waqar Ahmed for reporting & helping out ).
  • No image optimization or criticalcss attempts on localhost installations any more + notification of that fact if localhost detected.
  • Some other minor changes/ improvements/ filters, see the GitHub commit log.

3.1.2

  • Google Fonts: some more removal logic
  • fix for 404 fallback bug (hat tip to Asif for finding & reporting)
  • Some other minor changes/ improvements/ filters, see the GitHub commit log.

3.1.1.1

  • Quick workaround for an autoload conflict with JetFormBuilder (and maybe other Crocoblock plugins?) that causes a critical error on the AO settings page.

3.1.1

  • images: when optimizing images and lazyloading is on, then by default do not set an LQIP (low quality image placeholder) any more (reason: it might look nice but it comes with a small-ish perf. penalty). This can be re-enabled by returning true to the autoptimize_filter_imgopt_lazyload_dolqip filter.
  • security: further improvements to critical CSS settings page (again with the great assistance of WPScan Security).
  • some other minor changes/ improvements/ filters, see the GitHub commit log.

3.1.0

  • new HTML sub-option: “minify inline CSS/ JS” (off by default).
  • new Misc option: permanently allow the “do not run compatibility logic” flag to be removed (which was set for users upgrading from AO 2.9.* to AO 3.0.* as the assumption was things were working anyway).
  • security: improvements to the critical CSS settings page to fix authenticated cross site scripting issues as reported by WPScan Security.
  • bugfix: “defer inline JS” of very large chunks of inline JS could cause server errors (PCRE crash actually) so not deferring if string is more then 200000 characters (filter available).
  • some other minor changes/ improvements/ hooks, see the GitHub commit log

3.0.4

  • fix for “undefined array key ao_post_preload” on post/ page edit screens
  • fix for image optimization altering inline JS that contains an <img tag if lazyload is not active
  • improvements to exit survey
  • 确认工作于 WordPress 4.1

3.0.3

  • fix for images being preloaded without this being configured when lazyload is on and per page/post settings are off.
  • ensure critical CSS schedule is always known.
  • when deferring non-aggregated JS, make the optimatization exclusions take the full script-tag into account instead of just the src URL.

3.0.2

  • rollback automatic “minify inline CSS/ JS” which broke more then expected, this will come back as a separate default off option later and can now be enabled with a simple filter: add_filter( 'autoptimize_html_minify_inline_js_css', '__return_true'); .
  • fix for “Call to undefined method autoptimizeOptionWrapper::delete_option()” in autoptimizeVersionUpdatesHandler.php

3.0.1

  • fix for minification of inline script with type text/template breaking the template (e.g. ninja forms), hat tip to @bobsled.
  • fix for regression in import of CSS-files where e.g. fontawesome CSS was broken due to being escaped again with help of @bobsled, thanks man!

3.0.0

  • fundamental change for new installations: by default Autoptimize will not aggregate JS/ CSS any more (HTTP/2 is ubiquitous and there are other advantages to not aggregating esp. re. inline JS/ CSS and dependancies)
  • new: no API needed any more to create manual critical CSS rules.
  • new: “Remove WordPress blocks CSS” option on the “Extra” tab to remove block- and global styles (and SVG).
  • new: compatibility logic for “edit with elementor”, “revolution slider”, for non-aggregated inline JS requiring jQuery even if not excluded (= auto-exclude of jQuery) and JS-heavy WordPress blocks (Gutenberg)
  • new: configure an image to be preloaded on a per page/ post basis for better LCP.
  • improvement: defer inline now also allowed if inline JS contains nonce or post_id.
  • improvement: settings export/ import on critical CSS tab now takes into account all Autoptimize settings, not just the critical CSS ones.
  • technical improvement: all criticalCSS classes were refactored, removing use of global variables.
  • technical improvement: automated unit tests on Travis-CI for PHP versions 7.2 to 8.1.
  • fix: stop Divi from clearing Autoptimize’s cache which is pretty counter-productive.
  • misc smaller fixes/ improvements, see the GitHub commit log

older