Optimize Your Application with Laravel Page Speed

Optimize Your Application with Laravel Page Speed

Laravel Page Speed is a package by Renato Marinho for optimizing your Laravel site automatically. Page Speed is inspired by Google’s mod_pagespeed, and providing the following options:

  • inline_css inlines small external CSS files
  • elide_attributes removes unnecessary attributes in HTML tags
  • insert_dns_prefetch injects tags in the HEAD to enable the browser to do DNS prefetching
  • remove_quotes removes unnecessary quotes in HTML tags
  • trim_urls removes unnecessary prefixes from URLs
  • collapse_whitespace removes unnecessary whitespace in HTML
  • remove_comments removes HTML comments

More options are on the package’s roadmap, such as combine_css to combine multiple CSS files into one, and combine_javascript which does the same thing for JavaScript files.

The optimizations work by defining a middleware for each rule, which you could group in order to apply them to a route or group of routes.

You can skip routes by defining them in the configuration file that ships with the package:

'skip' => [
    '*.pdf', // Ignore all routes with final .pdf
    '*/downloads/*',// Ignore all routes that contain 'downloads'
]

Check out the Laravel Page Speed official repository for more information on installing this package and contributing to the planned rules.


Filed in: News


Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Software Engineer Lead (PHP)
Remote
CivicPlus, LLC
Full-time Senior Web Developer
Detroit, MI
Wayne State University
Senior Software Engineer
Sydney, Australia
FoodByUs
Full Stack Engineer
Remote or Medford, Oregon
Empire Medical
Laravel Developer (fulltime - Dutch only)
Netherlands
Qbixx | Webservices
Full Stack or Back-End Developer
Alexandria, VA; Tallahassee, FL; Orlando, FL
Marketing for Change
Senior Quality Assurance Engineer
Remote
Bisnow Media