siteation/magento2-pagespeed 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

siteation/magento2-pagespeed

最新稳定版本:1.0.1

Composer 安装命令:

composer require siteation/magento2-pagespeed

包简介

Back Forward Cache, Speculation Rules and View Transitions for Magento2

README 文档

README

Warning

This module is DEPRECATED. The main issue this module addressed (bfcache compatibility in Magento 2) is being solved in the Magento core via Pull Request #40750. We recommend migrating to the official Magento solution or using the patch provided in the PR.

Deprecation & Migration Guide

This project is no longer maintained. The core functionality is now better served by the upcoming official Magento 2 implementation.

Why Deprecate?

The primary goal of this module was to enable Back/Forward Cache (bfcache) support and modern browser features in Magento 2. These are now being addressed directly in the Magento core:

  • Magento Core PR: magento/magento2#40750
  • Patch Suggestion: You can apply the fix manually using the patch suggested here.
  • Hyvä Docs: The solution is also documented on the Hyvä Docs which points to the Magento 2 PR.
  • Mage Script: This patch is also applied automatically via the Mage Script until it is merged into the Magento core.

Migration

If you are currently using this module, we recommend:

  1. Uninstalling this module:
    bin/magento module:disable Siteation_Pagespeed
    composer remove siteation/magento2-pagespeed
  2. Applying the official Magento 2 patch (as linked above) to your project until it is officially merged into a stable release.
  3. Review the Hyvä Docs on bfcache for additional frontend-specific optimizations.

Packagist Version License Supported Magento Versions Hyvä Supported Breeze Supported

A Magento 2 module that leverages modern web performance technologies including Back/Forward Cache (bfcache), Page Prerendering, and View Transitions API to dramatically improve Core Web Vitals and overall page speed performance.

This module provides optimizations to enhance your store's loading times and create seamless user experiences.

Installation

Install the package via;

composer require siteation/magento2-pagespeed
bin/magento module:enable Siteation_Pagespeed

How to use

The Pagespeed has the bfcache feature enabled by default.

For the speculation rules and view transitions you need to enable them from the configuration.

each option can be found in the Magento admin panel under Stores > Configuration > Siteation > Pagespeed.

Use with Hyvä Themes

This module is fully compatible with Hyvä Themes, allowing you to take advantage of its performance optimizations while using this modern frontend solution.

But do note Hyvä Themes has its own speculation rules and view transitions, so for Hyvä it is best to disable the default speculation rules and view transitions provided by Hyvä in favor of this module.

Improved UX with bfcache

While this module makes sure to reload the customer data, it can not close the menus and other modals automatically.

This requires a update in the code of this component to handle the closing of these elements when the page is restored from the bfcache.

For this you can use the following snippets:

Hyvä Code Snippet

In your copy of vendor/hyva-themes/magento2-default-theme/Magento_Theme/templates/html/header/menu/mobile.phtml edit the follwing:

<nav
    x-data="initMenuMobile<?= $escaper->escapeHtml($uniqueId) ?>()"
    @keydown.window.escape="closeMenu()"
    class="z-20 order-2 sm:order-1 lg:order-2 navigation lg:hidden w-12 h-12"
    aria-label="<?= $escaper->escapeHtmlAttr(__('Site navigation')) ?>"
    role="navigation"
+++ x-bind="eventListeners"
>
const initMenuMobile<?= $escaper->escapeHtml($uniqueId) ?> = () => {
    return {
        mobilePanelActiveId: null,
        open: false,
        init() {
            this.setActiveMenu(this.$root);
        },
+++     eventListeners: {
+++		    ['@pageshow.window'](event) {
+++             if (event.persisted) {
+++                 this.open = false
+++             };
+++         }
+++     },
Breeze Code Snippet

In your copy of vendor/swissup/module-breeze/view/frontend/web/js/components/menu.js edit the follwing:

    this._on(document, 'keydown', e => {
        if (e.key === 'Escape' && $('html').hasClass('nav-open')) {
            this.close();
        }
    });

+++ this._on(window, "pageshow", e => {
+++     if (e.persisted) {
+++         this.close();
+++     }
+++ });
},

For Luma sadly we have no equivalent solution available at this time.

siteation/magento2-pagespeed 适用场景与选型建议

siteation/magento2-pagespeed 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 1.08k 次下载、GitHub Stars 达 26, 最近一次更新时间为 2025 年 08 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「magento2」 「magento2-module」 「magento2-hyva」 「magento2-breeze」 「bfcache」 「speculation-rules」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 siteation/magento2-pagespeed 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 siteation/magento2-pagespeed 我们能提供哪些服务?
定制开发 / 二次开发

基于 siteation/magento2-pagespeed 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.08k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 26
  • 点击次数: 22
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 26
  • Watchers: 1
  • Forks: 1
  • 开发语言: HTML

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-23