Speed Up And Optimize The Performance Of Laravel Application - PowerPoint PPT Presentation

View by Category
About This Presentation
Title:

Speed Up And Optimize The Performance Of Laravel Application

Description:

Are you looking to enhance speed and optimize your Laravel application? View our presentation, we will guide you on how to improve Laravel application performance and reduce load with examines route and configuration caching, queues, database caching & more. – PowerPoint PPT presentation

Number of Views:15

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Speed Up And Optimize The Performance Of Laravel Application


1
-A publication of i-Verve Inc -
Increase Speed and Optimize the Performance of
Laravel Application
2
(No Transcript)
3
If we say that Laravel is the first choice of the
PHP developer, residing in any part of the world,
it is not an overstatement. Just check out all
online forums and discussion groups for PHP
communities and you will find a common voice
amongst them- Laravel has revitalized the way PHP
development is done. It is the first choice of
PHP developers for many years due to the
unparalleled advantages it offers to the
developers. Furthermore, a large Laravel
community also makes it easier for developers to
solve doubts and queries.
Though there is a problem with Laravel. Take any
Laravel application and you will find
that the Laravel application performance is not
up to the mark.
What is the main reason for such a low
performance and speed of Laravel application? It
is the tons of work happening on the backside
that makes it sure that you have a good time as a
developer. Whenever you make a feature run on
Laravel, it has to work on layers of code to be
whipped up to execute the command. It is the
main reason why Laravel application is slow
compared to other applications made of different
programming languages. In a cut-throat
competition era where users are restless and with
multiple options at their disposal to choose
from, they expect speed and smooth performance of
any web apps they are using. If you fail to
offer that, they will simply switch to your
rivals. It is not a condition that you want to
face off, do you? It is very crucial to take
some measures for optimization of Laravel
application and it is possible too. All you need
to do is to read this blog carefully till it ends
and gain some insight and information about how
to improve the speed and performance of Laravel
application.
4
Lets get started. First of all, lets see how to
optimize your Laravel app for 100/100 page speed
score.
Google Page Speed insights are very crucial to
determine the speed and performance of web
applications. Significantly, your app scores are
high when the Page Speed is measured. The process
is split into four small elements.
5
Images Scripts Styles Server Speed 1.
Images optimizing images are a very important
thing to do if you want to improve the speed
of the Laravel web application. There might be
static images or images that are part of the
design of the web application. There are
different tools to be used for different images
for image optimization. Some of the tools help
for image optimization is PNGcrush Gifsicle
Joegoptim
yum install -y libjpeg-turbo-devel ./configure
make make strip make install
6
Now, lets see how images are optimized for
better speed and performance of a Laravel
application. These are some scripts that can be
used for image optimization. For PNG photos
find .-type f -name ".png"-printf'p\n'-exec
pngcrush-ow -q -reduce -brute "" \
For JPG photos
find .-type f \(-name ".jpg"-o -name ".jpeg"
\)-exec jpegoptim--strip-all --all-progressive
"" \
Also, you can use a framework called
Laravel-Image-Optimizer, a very superior image
optimization tool for Laravel.
7
  • Scripts
  • When you use Laravel, you are automatically using
    Elixir and Mix, a script merging and minimizing
    tools. However, when it comes to external scripts
    such as Google Analytics scripts or MailChimp
    scripts, we need to download and merge the
    scripts with the internal scripts. It is easy to
    manage one file that has internal and external
    scripts.
  • Styles
  • When it comes to styles, you need to ensure that
    you end up minimizing them too. However, it is a
    hard task and you need to ensure that you come up
    with styles that are easy to load while rendering
    the main page.
  • Server Speed
  • If you are using Apache HTTP server, you can
    improve the performance of the app by picking
    from HTML5 Boilerplate Source Code and move them
    to your Apache config.
  • For application response time, you need to check
    out the slow queries or external services that
    your app is using such as external API calls and
    mail sending facilities.
  • When it comes to minifying output HTML, create a
    middleware that improves the response time and
    minify HTML output.

8
A good example is shown in the image below.
9
How to compress images and reduce image
sizes? Yes, with a Laravel web application, it is
important to compress images to improve the speed
and performance of the application. There are
different code snippets and methods by which you
can surely compress your Laravel application
images. It is obvious that large images take more
time to load the page and it is a frustrating
thing for users to wait for more than a few
seconds to load the page. Google came up with
an excellent tool called Squoosh app for image
compression and size reduction. Most of the
Laravel developers use this app only. However,
there are some other tools available for the job
also such as Tinyjpg. Also, there is the Laravel
Image Optimizer by Spatie that can optimize
different types of images such as PNGs, JPGs,
SVGs and GIFs by running these images through a
chain of various tools for image optimization.
10
Laravel Speed Test with Ping Dom
11
No matter how attractive, feature-rich and
functional your website is, if it is not quick at
loading and performing superiorly when opened,
there is nothing to gain there. Your website will
not serve the core purpose for which you have
built it in the first place. If you are hiring a
Laravel application development company, you
need to check out the speed of the websites they
have built previously and you will come to know
about the competence and expertise the company
possesses. In most of the Laravel web
application development projects, developers give
more emphasis on UI and UX rather than speed of
the webpage. I am not saying that UI and UX are
not important, but so is speed. Do you like
waiting for minutes for a page to reload when you
open any website? Well, no one likes. If the
websites loading speed is not satisfactory, you
might notice a high bounce rate and smaller
session time. Even your efforts for SEO will go
in vain if your websites speed is not good.
Not just SEO rankings, you will end up losing
your loyal customers who prefer speed over
anything else. Hence, it is of utmost importance
that you check your website speed and keep
checking and optimizing it from time time.
12
Some Tips For Speed Optimization Of The Laravel
Website First and foremost, you need to rework on
your web design. For example, Google Maps or some
other 3rd party tools might generate some errors
that in turn, decide your speed. Also, heavy CSS
and JavaScript needed to be refactored to make
them smaller. The best way is to use a template
that is well coded and does not use many
Plugins. Configure web server Your web server
needs to be configured properly to improve the
speed of the web application. What a web server
does? It controls gzip and cache settings that
are required for a high ranking score. What to
do for web server configuration? For caching,
enable caching on JS/CSS/Images for at least 7
days. For gziping, you need to gziped all your
files to improve the page speed score. Hire
Laravel developers from a leading Laravel
development company who have in-depth knowledge
and experience of configuring web servers. Ask
them about it while taking their
interviews. Laravel configuration For Laravel
application configuration, you need to do the
following things. Minify CSS/JS It is very easy
and can be done by using tools such as Elixir.
You can also do it by manually minifying and
combining your CSS/JS.
13
Cache 3rd party resources The main issue arising
here is that Google Analytics sets a low cache
time and Page Speed Insights requires a long
cache time. You need to catch the script locally
temporary to improve the page speed. Template
putting up into Laravel Once you have selected
the template for the website you need to put it
in Laravel. First of all, you need to copy
assets. Copy the templates js/css asset folders
into resources/assets/ and then copy the
templates fonts folder into public/. Then you
need to download third party resources such as
jQuery and bootstrap into your resources/fonts
folders.
elixir(function(mix) mix.styles( 'bootstrap.cs
s', 'clean-blog.css', 'font-awesome.css', ,
'public/assets/css') mix.scripts( 'jquery.min.j
s', 'bootstrap.min.js', 'clean-blog.js', ,
'public/assets/js/') )
With gulpfile.js creation, combine all the assets
and combine them into 1 script. Now, you have
minified CSS and js that can be updated with the
code.
14
HTML updation To update HTML, you need to remove
all CSS link tags combined into all.css and then
replace it with the following.
ltstylegtlt?php include app_path() .
'/../public/assets/css/all.css' ?gtlt/stylegt
Then you need to replace all the
ltstylegtlt?php include app_path() .
'/../public/assets/css/all.css' ?gtlt/stylegt
CSS optimization keeping CSS minimal and clean is
essential and hence, you need to remove all the
comments and other stuff that are of no
use. Image optimization if you use CMS, install
some Plugins to optimize images or you can go to
compresser.io and optimize all the images. Fonts
optimization It is also important to improve the
speed of the website and it can be done by
hosting all fonts locally or by downloading
Google Fonts and update the CSS accordingly.
15
How to improve Laravel performance?
16
Minimize plugins One of the main parameters that
slow down the loading speed of Laravel
application is using too many plugins for
different functionalities and features. There is
a large number of plugins available for Laravel
web application and with these plugins, more
libraries and files come that take too much time
for loading. You need to get rid of unnecessary
plugins that you are using to improve the
Laravel web application performance and
speed. Use eager Loading of your data For easy
and smooth CRUD (create, retrieve, update,
delete) operations, Laravel uses Eloquent ERM
supports mapping of your object models to the
database tables supporting it and handles
database interaction. However, Eloquent uses a
lazy loading approach that asks a special query
and reference in the code for data retrieval. It
might result in a lot of queries and might reduce
performance. Eager Loading aspect is much more
convenient and easy. By making queries to use
eager Loading, they will retrieve any associated
object models and will be available to use at any
given time.
17
See below image for more information. Lazy
Loading approach
books App\Bookall() foreach (books as
book) echo book-gtauthor-gtname
Eager Loading Approach
books App\Bookwith('author')-gtget()
foreach (books as book) echo
book-gtauthor-gtname
Use Deployment Tool for Command Invoke Well, we
cannot tell that it will improve the performance
of the Laravel application, but it will reduce
the loading time. A Deployer is a fantastic tool
for PHP that can be used to invoke all commands
and to deploy applications Migrations, seedes,
optimization commands with a single command.
18
Use caching Use the Laravel model caching to
cache anything that you can for each dictionary.
Once it has saved and updated an eloquent
object, it will automatically invalidate itself.
Even you can cache full response if your website
is static. Precompile assets It is important to
have all your assets in separate files during the
development stage, but not for production. So,
before deployment, there are few artisan commands
that you can use for this purpose.
php artisan optimize php artisan configcache
php artisan routecache
It will help you to compile all the classes that
you use frequently into a single file and also
help you to combine your routes and
configuration files into single files. It will
lead to faster loading website and thats what
you are looking for.
19
Conclusion When it comes to improving the speed
and performance of Laravel application, there are
so many possibilities available for you. All you
need to do is to carefully evaluate all the
possibilities and follow Laravel performance tips
described in this post. Surely, it will lead to
faster loading website with superior performance
and smooth navigation.
If you need to know more information about
Increase Speed and Optimize the Performance of
Laravel Application, Learn here -
https//i-verve.com/blog/laravel-
speed-and-performance-optimization
?
?
About PowerShow.com