定制 mage2kishan/module-performance-optimizer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

mage2kishan/module-performance-optimizer

Composer 安装命令:

composer require mage2kishan/module-performance-optimizer

包简介

Frontend performance optimizations for Magento 2 — script deferral, font-display swap, CLS prevention, iframe lazy loading. Designed for Hyva and Luma storefronts.

README 文档

README

Magento 2 Performance Optimizer: Script Deferral, Font-Display Swap, CLS Prevention and Iframe Lazy Loading (Hyva + Luma)

Magento 2.4.4 - 2.4.8 PHP 8.1 - 8.4 Hyva + Luma Live Demo & Details Packagist Upwork Top Rated Plus Website

Fix Core Web Vitals on your Magento 2 store without touching a single template. Panth Performance Optimizer adds five admin-configurable frontend optimizations: third-party script deferral, font-display swap, Alpine.js CLS prevention, automatic image dimensions, and iframe lazy loading. Every setting is a checkbox. Works on both Hyva and Luma storefronts.

Product page: kishansavaliya.com/magento-2-performance-optimizer.html

Quick Answer

What is Panth Performance Optimizer? It is a Magento 2 extension that improves Core Web Vitals and page speed by injecting five frontend optimizations from admin configuration, with no theme edits or template changes needed.

What does it add to my store?

  • Script deferral that adds defer to third-party scripts (analytics, chat widgets, pixels) to cut main-thread blocking.
  • font-display: swap to stop custom fonts from blocking text rendering (fixes FOIT).
  • x-cloak CSS injection to prevent Alpine.js elements from flashing raw markup before hydration (essential for Hyva).
  • Auto image dimensions that add missing width and height attributes to reduce CLS.
  • Iframe lazy loading that defers YouTube, Maps, and similar embeds until they scroll into view.

Which themes are supported? Both Hyva and Luma. The x-cloak optimization is especially useful for Hyva stores.

What does it need? Magento 2.4.4 to 2.4.8, PHP 8.1 to 8.4, and the free mage2kishan/module-core package.

Need Custom Magento 2 Development?

Get a free quote for your project in 24 hours for custom modules, Hyva themes, performance work, M1 to M2 migrations, and Adobe Commerce Cloud.

Get a Free Quote

Kishan Savaliya

Top Rated Plus on Upwork

Hire on Upwork

100% Job Success • 10+ Years Magento Experience Adobe Certified • Hyva Specialist

Panth Infotech Agency

Magento Development Team

Visit Agency

Custom Modules • Theme Design • Migrations Performance • SEO • Adobe Commerce Cloud

Visit our website: kishansavaliya.com  |  Get a quote: kishansavaliya.com/get-quote

Table of Contents

Who Is It For

  • Hyva storefronts that need the x-cloak CSS fix applied early so Alpine.js components do not flash raw markup on load.
  • Stores with third-party scripts (Google Tag Manager, live chat, Facebook Pixel, analytics) that are blocking the main thread.
  • Merchants aiming for better Core Web Vitals scores who want LCP, CLS, and INP improvements without touching templates.
  • Stores with embedded videos and maps where YouTube, Vimeo, or Google Maps iframes are adding large payloads on initial load.
  • Any Magento store on Luma or Hyva where custom fonts are causing Flash of Invisible Text during page load.

Key Features

Defer Third-Party Scripts

  • Automatically adds defer to every <script> tag loading from a domain other than your storefront.
  • Excluded Domains field lets you whitelist payment gateways or scripts that need to run synchronously.
  • Reduces Total Blocking Time (TBT) and improves INP without manual script changes.

Font-Display Swap

  • Injects a global font-display: swap rule so browsers show fallback text immediately instead of hiding it while custom fonts download.
  • Eliminates Flash of Invisible Text (FOIT) across all CSS-loaded fonts on every page.
  • Improves LCP by letting browsers paint text faster.

x-cloak CLS Prevention

  • Injects [x-cloak]{display:none!important} into the page head early in the critical path.
  • Prevents Alpine.js template markup from flashing before hydration on Hyva storefronts.
  • A single checkbox that every Hyva store should turn on.

Auto Image Dimensions

  • Client-side script adds missing width and height attributes to <img> elements that do not have them.
  • Reads naturalWidth and naturalHeight for already-loaded images, attaches a load listener for images still loading.
  • Reduces CLS without any template edits.

Iframe Lazy Loading

  • Moves the src of below-the-fold iframes to data-lazy-src on DOMContentLoaded.
  • Uses IntersectionObserver with a 200px root margin to restore the src just before the iframe scrolls into view.
  • Cuts initial page weight from YouTube, Google Maps, Vimeo, and social widgets.

Admin-Friendly

  • Every optimization is its own checkbox in Stores > Configuration > Panth Extensions > Performance Optimizer.
  • No template edits, no layout XML changes, no code modifications needed.
  • All settings respect Magento's scope hierarchy (default, website, store view).
  • Fully translatable via standard Magento __() strings.

Compatibility

Requirement Versions Supported
Magento Open Source 2.4.4, 2.4.5, 2.4.6, 2.4.7, 2.4.8
Adobe Commerce 2.4.4, 2.4.5, 2.4.6, 2.4.7, 2.4.8
Adobe Commerce Cloud 2.4.4 to 2.4.8
PHP 8.1.x, 8.2.x, 8.3.x, 8.4.x
Hyva Theme 1.0+ (native support, recommended)
Luma Theme Native support
Required Dependency mage2kishan/module-core (free)

Installation

Composer Installation (Recommended)

composer require mage2kishan/module-performance-optimizer
bin/magento module:enable Panth_Core Panth_PerformanceOptimizer
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f
bin/magento cache:flush

Manual Installation via ZIP

  1. Download the latest release from Packagist or from the product page.
  2. Extract it to app/code/Panth/PerformanceOptimizer/ in your Magento install.
  3. Make sure Panth_Core is installed too (required dependency).
  4. Run the commands above starting from bin/magento module:enable.

Verify Installation

bin/magento module:status Panth_PerformanceOptimizer
# Expected: Module is enabled

After install, open:

Admin -> Stores -> Configuration -> Panth Extensions -> Performance Optimizer

Configuration

Go to Stores -> Configuration -> Panth Extensions -> Performance Optimizer.

Setting Group Default Description
Enable Performance Optimizer General Settings Yes Master toggle. When disabled, no optimizations are injected.
Defer Third-Party Scripts Script Optimization Yes Adds defer to third-party <script> tags to reduce main-thread blocking.
Excluded Domains Script Optimization (empty) One domain per line. Scripts from these domains will not be deferred.
Add font-display: swap Font Optimization Yes Injects a global CSS rule that forces font-display: swap on all @font-face declarations.
Add x-cloak Style Layout Stability (CLS Prevention) Yes Injects [x-cloak]{display:none!important} to prevent Alpine.js elements flashing on Hyva.
Set Image Dimensions Layout Stability (CLS Prevention) Yes Adds missing width and height attributes to images to reduce CLS.
Enable Iframe Lazy Loading Iframe Lazy Loading Yes Defers below-the-fold iframes using IntersectionObserver until they scroll into view.

After changing any setting, flush the full-page cache:

bin/magento cache:flush

How It Works

  1. When a page loads, the module reads your configuration and injects only the optimizations you have enabled.
  2. Script deferral uses a MutationObserver to catch both inline and dynamically injected third-party scripts and sets defer = true.
  3. Font swap adds a <style> block early in the <head> with @font-face { font-display: swap !important }.
  4. x-cloak injects [x-cloak]{display:none!important} before Alpine.js initializes so hidden-until-ready elements never flash.
  5. Image dimensions runs after page load, reads naturalWidth and naturalHeight, and sets the attributes on any <img> that was missing them.
  6. Iframe lazy loading moves below-fold iframe src values to data-lazy-src on DOMContentLoaded, then an IntersectionObserver with 200px margin restores them as they approach the viewport.

Each optimization is independent. You can enable or disable any one of them without affecting the others.

FAQ

Do I need to edit any templates?

No. Every optimization is admin-configurable and injected automatically. Enable the module, set your checkboxes, flush cache, and the changes take effect on your live store.

Will deferring scripts break my payment gateway or chat widget?

No, as long as you add the domain to the Excluded Domains field. Scripts from excluded domains are left untouched. For the vast majority of analytics, pixels, and chat tools, defer is safe with no side effects.

Does this work on Hyva?

Yes. Hyva is where the x-cloak optimization matters most. Every Hyva store should enable it. The module also works on Luma with no extra setup.

Can I disable individual optimizations?

Yes. Each of the five optimizations has its own toggle. You can combine them any way you like without affecting the others.

Does this replace my CDN or full-page cache?

No. Performance Optimizer focuses on frontend render-path fixes that CDN and FPC cannot address. Use it alongside your caching setup.

Is it compatible with Google Analytics, GTM, and Facebook Pixel?

Yes. These scripts handle defer correctly. If you ever see an issue with a specific script, add its domain (for example googletagmanager.com) to the Excluded Domains list.

Does it support multi-store setups?

Yes. All settings respect Magento's scope hierarchy (default, website, store view), so you can configure optimizations differently per store.

Will it help my SEO rankings?

Core Web Vitals (LCP, CLS, INP) are confirmed Google ranking signals. Improvements to these metrics can positively affect your organic search visibility.

Does Panth Performance Optimizer need Panth Core?

Yes. mage2kishan/module-core is a free, required dependency that Composer installs for you automatically.

Support

Channel Contact
Product Page kishansavaliya.com/magento-2-performance-optimizer.html
Email kishansavaliyakb@gmail.com
Website kishansavaliya.com
WhatsApp +91 84012 70422
GitHub Issues github.com/mage2sk/module-performance-optimizer/issues
Upwork (Top Rated Plus) Hire Kishan Savaliya
Upwork Agency Panth Infotech

Response time: 1-2 business days.

Need Custom Magento Development?

Looking for custom Magento module development, Hyva theme work, Core Web Vitals consulting, or performance tuning? Get a free quote in 24 hours:

Get a Free Quote

Hire on Upwork    Visit Agency    View Product Page

About Panth Infotech

Built and maintained by Kishan Savaliya (kishansavaliya.com), a Top Rated Plus Magento developer on Upwork with 10+ years of eCommerce experience.

Panth Infotech is a Magento 2 development agency that builds high quality, security focused extensions and themes for both Hyva and Luma storefronts. The extension suite covers SEO, performance, checkout, product presentation, customer engagement, and store management, with each module built to MEQP standards and tested across Magento 2.4.4 to 2.4.8.

Browse the full extension catalog on our Magento extensions page or on Packagist.

Quick Links

Resource Link
Product Page magento-2-performance-optimizer.html
Packagist mage2kishan/module-performance-optimizer
GitHub mage2sk/module-performance-optimizer
Website kishansavaliya.com
Free Quote kishansavaliya.com/get-quote
Upwork (Top Rated Plus) Hire Kishan Savaliya
Upwork Agency Panth Infotech
Email kishansavaliyakb@gmail.com
WhatsApp +91 84012 70422

Ready to improve your Magento 2 Core Web Vitals?
See Performance Optimizer

SEO Keywords: magento 2 performance optimizer, magento 2 core web vitals, magento 2 defer scripts, magento 2 defer third-party scripts, magento 2 font display swap, magento 2 cls prevention, magento 2 cumulative layout shift fix, magento 2 lazy loading iframes, magento 2 iframe lazy load, magento 2 image dimensions, magento 2 x-cloak hyva, magento 2 alpine cloak, magento 2 lcp optimization, magento 2 inp optimization, magento 2 tbt reduction, magento 2 render blocking scripts, magento 2 performance module, magento 2 speed optimization extension, magento 2 page speed, hyva performance optimizer, luma performance optimizer, panth performance optimizer, magento 2 page speed insights, magento 2 seo core web vitals, magento 2.4.8 performance, php 8.4 magento performance, hire magento performance developer, top rated plus magento freelancer, kishan savaliya magento, panth infotech magento, mage2kishan, mage2sk, magento 2 hyva performance optimization, magento 2 luma performance tuning, magento 2 frontend optimization, magento 2 lighthouse optimization

mage2kishan/module-performance-optimizer 适用场景与选型建议

mage2kishan/module-performance-optimizer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 39 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 04 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 mage2kishan/module-performance-optimizer 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 39
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 49
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2026-04-14