How to optimize website speed and performance in Laravel?

How to optimize website speed and performance in Laravel?

In this post we will give you information about How to optimize website speed and performance in Laravel?. Hear we will give you detail about How to optimize website speed and performance in Laravel?And how to use it also give you demo for it if it is necessary.

It is very important for every website to quick load that means your website should load in few seconds like 4 or 5. We are always fetching issues about page speed like how to increase website speed in laravel, how to reduce loading time of website in laravel, is it possible speed up php execution time of my website, how to optimize php laravel script to increase speed, how to speed up web browsing in laravel. So basically you have several question regarding to improve your website performance in laravel.

However, There are several composer packages available for increase website page speed in php laravel. So here i found “laravel-page-speed” composer package for 35%+ optimization of your website.

laravel-page-speed package will minify HTML output and it can be optimization your web page. laravel-page-speed package will delete unused attributes in HTML tags, delete unused quotes in HTML tags, delete unused prefixes from URLs, delete unused whitespace in HTML, delete HTML comments. Also there are several feature. They also minify css and minify js files. There are several things done with this page and i am sure it make better performance at it was before.

Here, i will give you very small example with screen shot. I created simple bootstrap file and with simple table. If i see in “CTRL + u” and see source code then i can see too many white space and if anything unused attribute etc. After used this package you can see on source all white space remove and clean with quick run code.

So here i attach both small and simple example screen shot, so you can understand how it can help you. After that you can see how it works.



As you can see how it optimization and help you. So just follow few step and get simple example:

Step 1: Install laravel-page-speed Composer Package

first thing is that we have to add laravel-page-speed package for improve page speed so one your cmd or terminal and fire bellow command, Make sure laravel-page-speed package support laravel 5.3, laravel 5.4, laravel 5.5 and laravel 5.5 + version of laravel.

composer require renatomarinho/laravel-page-speed

After successfully install package, open config/app.php file and add service provider and alias.


'providers' => [





You can publish the default configuration file by following command:

php artisan vendor:publish --provider="RenatoMarinhoLaravelPageSpeedServiceProvider"

After that you have to register your middleware on Kernel.php file so, do like as bellow:



namespace AppHttp;

use IlluminateFoundationHttpKernel as HttpKernel;

class Kernel extends HttpKernel




* The application's route middleware groups.


* @var array


protected $middlewareGroups = [

'web' => [














Step 2: Make Route

In this is step we need to create route display simple layout file. so open your routes/web.php file and add following route.


Route::get('mySource', function () {

return view('mySource');


Also see:Laravel – Google reCaptcha Code using anhskohbo/no-captcha

Step 3: Create Blade File

In Last step, let’s create mySource.blade.php(resources/views/mySource.blade.php) for layout and we will write design code here and put following code:


Also see:Laravel 5.5 CRUD Example from scratch

<!DOCTYPE html>



<title>My Source</title>

<link rel="stylesheet" href="" />



<div >

<h1>My Source</h1>

<table >







































Now, you are ready to run example.

You can get more information about laravel-page-speed plugin from here : laravel-page-speed

I hope it can help you….

Hope this code and post will helped you for implement How to optimize website speed and performance in Laravel?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

  +  39  =  46

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US