定制 sitegeist/slipstream 二次开发

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

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

sitegeist/slipstream

Composer 安装命令:

composer require sitegeist/slipstream

包简介

Teleport any HTML tag to antoher place of the document. Mostly used for CSS and JS

README 文档

README

Header requirements for presentational fusion

"Quantum slipstream transcends the normal warp barrier by penetrating the quantum barrier with a focused quantum field."

The slipstream package allows defining header requirements with presentational fusion by labeling the required tags with a unique attribute. They are later deduplicated and moved to the target position. This allows defining additional the JS and CSS requirements directly with the presentational fusion components.

Authors & Sponsors

The development and the public releases of this package is generously sponsored by our employer sitegeist.

Usage

You can mark any HTML fragment to be moved to the head of the document by adding a data-slipstream attribute.

<script data-slipstream src="yourCustomScript.js"></script>
<div>your component</div>

The slipstream middleware will parse the entire page and detect all those tags. The tags are then removed from the original location and are appended to the header. Every tag is added only once, so if multiple components require the same JS, only one is added to the given location.

Alter target by tag name

By defining the data-slipstream attribute with an tag name, the target can be altered.

<script data-slipstream="//body" src="yourCustomScript.js"></script>
<div>your component</div>

Using CSS selector (id or class name) as target

If you want to target a specific element with an id or class name you can also use a selector prefixed with an # (id) or an . (class name). The string itself musst start with a letter, underscore or hyphen. No spaces are allowed. Also multiple id and classes combinations won't work, only a single class name or id works.

<dialog data-slipstream="#bar"><p>Greetings, one and all!</p></dialog>
<dialog data-slipstream=".foo"><p>Greetings, one and all!</p></dialog>

Using XPATH selector as target

<script data-slipstream="//script[@defer]" src="yourCustomScript.js"></script>

Location of the tag

To prepend the tag to the given target, you can add the data-slipstream-prepend attribute:

<script data-slipstream="//body" data-slipstream-prepend src="yourCustomScriptAfterOpenendBody.js"></script>
<script data-slipstream data-slipstream-prepend src="yourCustomScriptAfterOpenendHead.js"></script>

To place a tag before or after a specific tag, you can add the data-slipstream-before or data-slipstream-after attribute:

<script data-slipstream="//script[@defer]" data-slipstream-before src="yourCustomScript.js" defer></script>
<script data-slipstream="//script[@defer]" data-slipstream-after src="yourCustomScript.js"></script>

Debug mode

When the setting Sitegeist.Slipstream.debugMode is enabled, HTML comments are rendered to mark where tags were removed and inserted. This is enabled in Development Context by default.

Remove slipstream attributes

If the setting Sitegeist.Slipstream.removeSlipstreamAttributes is enabled, the attributes from slipstream get removed. This is disabled in Development Context by default.

Inner working and performance

The slipstream HTTP middleware will modify all responses with an active X-Slipstream: Enabled HTTP header. This header is added to Neos.Neos:Page and Sitegeist.Monocle:Preview.Page already, so this will work for Neos and Monocle right away. You will have to add the header X-Slipstream: Enabled for other controllers.

Since the response body is parsed and modified, this adds a minor performance penalty to every request. However the package is designed to work together with Flowpack.FullpageCache, which will in turn cache the whole result and mitigate the slight performance drawback.

Installation

Sitegeist.Slipstream is available via packagist run composer require sitegeist/slipstream.

We use semantic-versioning so that every breaking change will increase the major version number.

Contribution

We will gladly accept contributions. Please send us pull requests.

sitegeist/slipstream 适用场景与选型建议

sitegeist/slipstream 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 89.8k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2020 年 09 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 sitegeist/slipstream 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 89.8k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 34
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 4
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2020-09-04