Skip to content
This repository was archived by the owner on Apr 1, 2021. It is now read-only.

Commit 476397d

Browse files
committed
add laravel page speed
1 parent fca6a28 commit 476397d

File tree

8 files changed

+151
-14
lines changed

8 files changed

+151
-14
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ PUSHER_APP_CLUSTER=mt1
3838
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
3939
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
4040

41+
LARAVEL_PAGE_SPEED_ENABLE=true
42+
4143
# API_URL=
4244
# API_USERNAME=
4345
# API_PASSWORD=

.env.travis

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ PUSHER_APP_CLUSTER=mt1
3838
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
3939
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
4040

41+
LARAVEL_PAGE_SPEED_ENABLE=true
42+
4143
# API_URL=
4244
# API_USERNAME=
4345
# API_PASSWORD=

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Notification using [Vue-SweatAlert2][vue-sweatalert2] and [Vue-Notification][vue-notification]
1515
* Loading spinner with [Vue Loading Spinner][vue-loading-spinner]
1616
* Quick deployment with [Docker Compose][docker-compose]
17+
* [Laravel Page Speed][laravel-page-speed], Simple package to minify HTML output on demand which results in a 35%+ optimization
1718

1819
## Requirement
1920
* **PHP** >= 7.1.3
@@ -85,15 +86,15 @@ npm run watch
8586
## or using Hot Module Replacement
8687
npm run hot
8788
```
88-
* Open browser, goto `http://localhost:8888`
89+
* Open browser, goto [http://localhost:8888](link)
8990

9091
### For Production
9192
* Create and start Container
9293
```
9394
docker-compose up -d prod
9495
```
9596

96-
* Open browser, goto [http://localhost:88](http://localhost:88)
97+
* Open browser, goto [http://localhost:88](link)
9798

9899
## License
99100
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
@@ -112,3 +113,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
112113
[docker-compose]: https://docs.docker.com/compose/
113114
[offline-plugin]: https://github.com/NekR/offline-plugin
114115
[workbox]: https://developers.google.com/web/tools/workbox/
116+
[laravel-page-speed]: https://github.com/renatomarinho/laravel-page-speed

app/Http/Kernel.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Kernel extends HttpKernel
2727
* @var array
2828
*/
2929
protected $middlewareGroups = [
30-
'web' => [
30+
'web' => [
3131
\App\Http\Middleware\EncryptCookies::class,
3232
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
3333
\Illuminate\Session\Middleware\StartSession::class,
@@ -37,10 +37,21 @@ class Kernel extends HttpKernel
3737
\Illuminate\Routing\Middleware\SubstituteBindings::class,
3838
],
3939

40-
'api' => [
40+
'api' => [
4141
'throttle:60,1',
4242
'bindings',
4343
],
44+
45+
'speed' => [
46+
// Laravel Page Speed
47+
\RenatoMarinho\LaravelPageSpeed\Middleware\InlineCss::class,
48+
\RenatoMarinho\LaravelPageSpeed\Middleware\ElideAttributes::class,
49+
\RenatoMarinho\LaravelPageSpeed\Middleware\InsertDNSPrefetch::class,
50+
\RenatoMarinho\LaravelPageSpeed\Middleware\RemoveComments::class,
51+
\RenatoMarinho\LaravelPageSpeed\Middleware\TrimUrls::class,
52+
\RenatoMarinho\LaravelPageSpeed\Middleware\RemoveQuotes::class,
53+
\RenatoMarinho\LaravelPageSpeed\Middleware\CollapseWhitespace::class,
54+
],
4455
];
4556

4657
/**
@@ -52,13 +63,13 @@ class Kernel extends HttpKernel
5263
*/
5364
protected $routeMiddleware = [
5465
// 'auth' => \App\Http\Middleware\Authenticate::class,
55-
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
56-
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
57-
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
66+
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
67+
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
68+
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
5869
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
59-
'can' => \Illuminate\Auth\Middleware\Authorize::class,
60-
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
61-
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
62-
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
70+
'can' => \Illuminate\Auth\Middleware\Authorize::class,
71+
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
72+
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
73+
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
6374
];
6475
}

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"fideloper/proxy": "^4.0",
1010
"guzzlehttp/guzzle": "^6.3",
1111
"laravel/framework": "5.7.*",
12-
"laravel/tinker": "^1.0"
12+
"laravel/tinker": "^1.0",
13+
"renatomarinho/laravel-page-speed": "^1.8"
1314
},
1415
"require-dev": {
1516
"filp/whoops": "^2.0",

composer.lock

Lines changed: 58 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/laravel-page-speed.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Enable Laravel Page Speed
8+
|--------------------------------------------------------------------------
9+
|
10+
| Set this field to false to disable the laravel page speed service.
11+
| You would probably replace that in your local configuration to get a readable output.
12+
|
13+
*/
14+
'enable' => env('LARAVEL_PAGE_SPEED_ENABLE', true),
15+
16+
/*
17+
|--------------------------------------------------------------------------
18+
| Skip Routes
19+
|--------------------------------------------------------------------------
20+
|
21+
| Skip Routes paths to exclude.
22+
| You can use * as wildcard.
23+
|
24+
*/
25+
'skip' => [
26+
'*.xml',
27+
'*.less',
28+
'*.pdf',
29+
'*.doc',
30+
'*.txt',
31+
'*.ico',
32+
'*.rss',
33+
'*.zip',
34+
'*.mp3',
35+
'*.rar',
36+
'*.exe',
37+
'*.wmv',
38+
'*.doc',
39+
'*.avi',
40+
'*.ppt',
41+
'*.mpg',
42+
'*.mpeg',
43+
'*.tif',
44+
'*.wav',
45+
'*.mov',
46+
'*.psd',
47+
'*.ai',
48+
'*.xls',
49+
'*.mp4',
50+
'*.m4a',
51+
'*.swf',
52+
'*.dat',
53+
'*.dmg',
54+
'*.iso',
55+
'*.flv',
56+
'*.m4v',
57+
'*.torrent'
58+
],
59+
60+
];

routes/web.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@
1111
|
1212
*/
1313

14-
Route::get('/{vue_capture?}', 'AppController@index')->where('vue_capture', '[\/\w\.\,\-]*');
14+
Route::get('/{vue_capture?}', 'AppController@index')
15+
->middleware(['speed'])
16+
->where('vue_capture', '[\/\w\.\,\-]*');

0 commit comments

Comments
 (0)