slexx/laravel-webp is a Laravel package for detect webp support in laravel framework.
It currently has 10 GitHub stars and 4.759 downloads on Packagist.
Install it with composer require slexx/laravel-webp.
Discover more Laravel packages by slexx
or browse all Laravel packages to compare alternatives.
Last updated
$ composer require slexx/laravel-webp
In Laravel 5.5 the service provider will automatically get registered. In older versions of the framework just add the service provider in config/app.php file:
'providers' => [
// ...
Slexx\LaravelWebp\LaravelWebpServiceProvider::class,
];
Add @webpJS directive to the <head> tag
<head>
@webpJS
<!-- ... -->
</head>
Usage in blade
@webp
<img src="https://raw.githubusercontent.com/slexx1234/laravel-webp/refs/heads/main/image.webp"/>
@else
<img src="https://raw.githubusercontent.com/slexx1234/laravel-webp/refs/heads/main/image.png"/>
@endwebp
or in js, php
if (supportsWebp()) {
// Does support!
} else {
// Does not support!
}
or in css
html.webp {
/* Does support! */
}
html.no-webp {
/* Does not support! */
}