定制 gitterdoc/critical 二次开发

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

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

gitterdoc/critical

最新稳定版本:1.0.0

Composer 安装命令:

composer require gitterdoc/critical

包简介

Laravel provider that will extract critical CSS.

README 文档

README

This package will resolve needed styles and pack it to the header. The rest of additional styles will be appended to the body and will be loaded after the page is ready. Warranty for google Pagespeed up to 100% and compatible with Bootstrap!

google PageSpeed: Desktop google PageSpeed: Mobile

📚 Installation

Go to your root directory of your laravel project and install the package with composer:

$ composer require gitterdoc/critical

And add the configuration's file to your laravel instance:

$ php artisan vendor:publish --provider="gitterdoc\Critical\Install"

💡 Usage

Go into your Blade template and replace your Stylesheets and add the same to the end of the body by expecting the second parameter!

<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
    <head>
        <!-- OLD -->
        <!--<link href="{{ asset('css/app.css') }}" rel="stylesheet" />-->

        <!-- To your header -->
        {{ critical('css/app.css', true) }}

        <!-- //… -->
    </head>
    <body>
        <!-- //… -->

        <!-- To your footer -->
        {{ critical('css/app.css', false) }}
    </body>
</html>

🔨 API

{{ critical($file, $type) }}

This method will handle your stylesheets.

Parameter Type Default Description
$file String required The stylesheet, that will be handled
$type boolean true It's an include for your header or your footer? (header = true, footer = false)

🔧 Settings

You can change the settings on the config/critical.php file.

Name Type Default env Description
enabled boolean true CRITICAL_ENABLED Enable or disable the Critical module
📝 onlyprint boolean true CRITICAL_ONLY_PRINT Describes the handling - true - Only stylesheets will be printed, no more handling - false - Each site request will be parsed to find specific styles
caching Array
enabled boolean true CRITICAL_CACHE_ENABLED Enable or disable the caching
time integer 3600 CRITICAL_CACHE_TIME Set the maximal cache lifetime of the cache in seconds (3600 = 1 hr)
📜 noscript boolean true CRITICAL_NOSCRIPT Adding original stylesheet as <noscript> for browsers, that don't have JavaScript enabled

🔥 Support us!

I'm a excellent and professional web- & software developer but i don't work anymore in these branche. I spend some free time to create awesome content. Support me by liking my repositorys 😍 or spend me a coffee ☕!

https://packagist.org/packages/gitterdoc/critical https://gitterdoc.com

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-07-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固