承接 zeroseven/critical-css 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

zeroseven/critical-css

Composer 安装命令:

composer require zeroseven/critical-css

包简介

README 文档

README

This extension creates the "critical css" dynamically for each page. Styles which have been integrated via PageRenderer or simple TypoScript are then automatically moved down from head to the end of the DOM.

Based on penthouse, a server running a service calls the single pages, determines the critical css and sends them back to TYPO3. If you change or move any content element, or update the page properties, the critical css will be flushed on this page and automatically recalculated.

Installation and setup

  1. Get this extension via composer req zeroseven/critical-css
  2. Get a free token here
  3. Store the token via the extension configuration in TYPO3 settings module

Flush critical css

If you need to recalculate the critical css on all pages, for example because you updated the page template, you can do this with just a single click:

Flush critical css

There are good reasons why "no admins" in TYPO3 shouldn't have this cache button. If they insist on needing it (they don't) then you can set the following option (you won't) in TSconfig:

options.clearCache.criticalCss = 1

Flush command:

This function can also be called via a TYPO3 command:

vendor/bin/typo3 critical_css:flush

Monitoring

A dashboard widget always gives you a good overview of how many pages are pending or expired, or just up-to-date.

Dashboard widget

Disable on some pages

The service calls the respective sites without POST or GET parameters or even without cookies or anything similar. Therefore it could make sense to deactivate the service for certain pages. In the backend, there's an extra button in the page properties for that.

1. Post or get parameters

For pages with content that mostly behaves dynamic, the service should be disabled. Let's take a search result page for example. The service will call this page without any search results, therefore making it impossible to consider the CSS of search results. This leaves the user with incomplete styling in the head area.

2. The record based detail pages problem (also called TRBDPP)

The critical css is stored in the database for each TYPO3 page. Unfortunately, extensions like the good old "news" extension, for example, offers one page for many records. For such "detail" pages you have to deactivate the service manually using the nicely styled button inside the page properties in the backend.

TODO: Create a Wikipedia article for "TRBDPP". LOL

PSR-14 Events

Register event listener

You can modify the behavior of the critical CSS generation by listening to PSR-14 events. To register your event listener, add the following configuration to your Configuration/Services.yaml:

services:
  Vendor\MyExtension\Event\MyCriticalCssEventListener:
    tags:
      - name: event.listener
        identifier: 'myextension/critical-css'
        event: Zeroseven\CriticalCss\Event\CriticalCssRequierdEvent

my_extensin/Classses/Event/CriticalCssEventListener.php:

....

use Zeroseven\CriticalCss\Event\CriticalCssRequierdEvent;

class CriticalCssEventListener
{
    public function __invoke(CriticalCssRequierdEvent $event): CriticalCssRequierdEvent
    {
        if ($event->getRequest()->hasHeader('X-SKIP-CRITICAL-CSS')) {
            $event->setRequiered(false);
        }

        return $event;
    }
}

zeroseven/critical-css 适用场景与选型建议

zeroseven/critical-css 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 05 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 zeroseven/critical-css 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-only
  • 更新时间: 2025-05-06