Render font awesome icons on the server side with Laravel 5
laravel-font-awesome is a good package which we can use to render awesome icons on the server side.
This package will render font awesome icons in your views on the server side. This removes the need to add extra JavaScript or webfont resources on the client side and in doing so reduces the size of your website significantly.
This is achieved by replacing the icons with their svg counterpart before sending the response to the client.
Installation
Install the package using Composer.
composer require jerodev/laravel-font-awesome
Service Provider
The package will be auto-discovered by Laravel. If you disabled auto-discovery, you should add the following provider to your config/app.php file.
\Jerodev\LaraFontAwesome\FontAwesomeServviceProvider::class,
Usage
To use Font Awesome icons in your view there are a few new blade directives.
// Let the package discover the best library for this icon. @fa('laravel')
// Define the library that should be used. @far('circle') // Regular @fas('circle') // Solid @fab('laravel') // Brands
Source Code
This post is submitted by our members. Submit a new post.
Tags: Tutorials Laravel 5.8 Laravel 5.7 Laravel 5.6 Laravel 5.5 Laravel 5.4 Laravel 5 Packages Sources