How to Optimize Website Speed and Performance in Laravel

How to improve website speed and performance in laravel? In this example, I will explain to you How to Optimize Website Speed and Performance in Laravel. In this tutorial, we will use laravel 5.6. We will use renatomarinho/laravel-page-speed package for increase website speed and performance in laravel. This package optimizes your website speed up to 35%.

This package has several things to improve speed like minify HTML output and it can be optimization your web page. This package will delete unused attributes in HTML tags, delete unused prefixes from URLs, delete unused quotes in HTML tags, delete HTML comments,delete unused whitespace in HTML.They also minify css and minify js files.

If your website has a low speed then definitely you will see the down SERP result in google. Google always prefer high-speed website priority. The website speed major effect in SEO. It is very important for every website to quick load that means your website should load in a few seconds like 4 or 5. If you want to more information about this package, then move to Github.

How to Optimize Website Speed and Performance in Laravel

We are going to Configure Laravel Project.

#1: Install Laravel Project

Install Laravel 5.6 Project by the typing following command.

$ composer create-project --prefer-dist laravel/laravel optimizewebsitespeed

#2: Create a View File

You can create a file in resources/views/data.blade.php and put this following code in it.

<!-- data.blade.php -->
<!DOCTYPE html>
	<title>How to Optimize Website Speed and Performance in Laravel</title>
	<link rel="stylesheet" href="{{asset('css/app.css')}}">
    <link href="" rel="stylesheet">
<div class="container">
	<h1>Optimize Website Speed and Performance in Laravel</h1>
	<table class="table table-bordered">

#3: Define Route

We register route in a web.php file.

Route::get('data', function () {
    return view('data');

You can see the output in the below screenshot.

Laravel Optimize Website Speed and Performance Example

#4: Install laravel-page-speed Package

Now we will install renatomarinho/laravel-page-speed composer package using by following command in our project.

$ composer require renatomarinho/laravel-page-speed

#5: Change Configuration

Laravel 5.5 and up

You don’t have to do anything else, this package uses the Package Auto-Discovery feature, and should be ready as soon as you install it via Composer.

Laravel 5.4 or 5.3

You can add the Service Provider to your config/app.php.

'providers' => [

You can publish the default configuration file by the following command(laravel 5.5+ follow below steps):

php artisan vendor:publish --provider="RenatoMarinho\LaravelPageSpeed\ServiceProvider"

You can register middleware in the app/Http/Kernal.php file.

protected $middleware = [

#6: Testing

php artisan serve

You can see output in below screenshot and compare to screenshot 1.

Laravel Increase Website Speed and Performance Example

What is happening? Because laravel speed package improves speed and performance.

At last, our How to Optimize Website Speed and Performance in Laravel is over.

Post Your Thoughts

This site uses Akismet to reduce spam. Learn how your comment data is processed.