How to include External CSS and JS file in Laravel 5

To include external CSS and JavaScript files in a Laravel 5 application, you can use the asset helper function.

For example, to include a CSS file, you can use the following code in your blade template:

<link href="{{ asset('css/style.css') }}" rel="stylesheet">

To include a JavaScript file, you can use the following code:

<script src="{{ asset('js/script.js') }}"></script>

The asset function generates a URL for the given file. It will automatically take care of generating a unique URL for the file based on its contents, so you don't have to worry about caching issues.

Watch a course Learn object oriented PHP

If you want to include a file from a package that you have installed using Composer, you can use the vendor function:

<link href="{{ asset('vendor/package/css/style.css') }}" rel="stylesheet">
<script src="{{ asset('vendor/package/js/script.js') }}"></script>

This will generate a URL for the file in the public directory of your application.