Http2Pusher
1.0.0
PHP HTTP2服务器推动器
HTTP/2推动允许Web服务器在浏览器请求之前将资源发送到Web浏览器。在大多数情况下,这是一种可以帮助某些网站加载速度的性能技术。 - 维基百科
图片由Cloudflare
使用作曲家: composer require melbahja/http2-pusher
获取实例:
require ' vendore/autoload.php ' ;
use Melbahja Http2 Pusher ;
$ pusher = Pusher:: getInstance ();示例:
// set css file
$ pusher -> link ( ' /assets/css/style.css ' );
// set css and image and src
$ pusher -> link ( ' /asstes/css/main.css ' )
-> src ( ' /assets/js/scripts.js ' )
-> img ( ' /assets/img/logo.png ' )
- set (Pusher:: IMG , ' /assets/img/logo2.png ' );
// set link with options
$ pusher -> link ( ' https://fonts.gstatic.com ' , [
' as ' => false ,
' rel ' => ' preconnect '
]);
// rel by default is preload
// as by default is the link type
// push header
$ pusher -> push (); Pusher::getInstance(): PusherInterface
Pusher::link(string $link, array $opts = []): PusherInterface
Pusher::src(string $link, array $opts = []): PusherInterface
Pusher::img(string $link, array $opts = []): PusherInterface
Pusher::set(string $type, string $link, array $opts = []): PusherInterface
Pusher::getHeader(string $type = null): string
Pusher::push(string $type = null): void
Pusher::public function toHeader(string $type, array $urls): null|string
麻省理工学院版权所有(C)2017 Mohamed Elbahja