Include External CSS and JS file in Laravel
Include External CSS and JS file in Laravel
In this tutorial, we will try to find the solution to "Include External CSS and JS file in Laravel" through programming.
You can include external CSS and JS file using asset helper method in Laravel. Place your CSS and JS file in public directory (**project/public**) and after that use asset method `{{ asset('style.css') }}` in href attribute of link tag and `{{ asset('custom.js') }}` in src attribute of script tag to add both javascript and css file in Laravel.-
Add external CSS and JS file in Laravel
To add external css and js file, follow these steps:
- create subfolders named css and js in public folder.
- Place style.css file in CSS folder.
- Place custom.js file in js directory.
- Open blade file.
- Place code in head tag of blade view file.
resources\views\welcome.blade.php
<link rel="stylesheet" href="{{ asset('css/style.css') }}"> <script src="{{ asset('js/custom.js') }}"></script>
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Define variable and use in Laravel controller method
- Laravel change date format
- How to get the id of last record from collection object in laravel view
- How to send email in Laravel 11
- Route not defined in Laravel
- How to get records in random order in laravel
- Target class [App\Http\Controllers\Auth\Request] does not exist.
- How to insert value to additional columns in pivot table in laravel
- Argument 1 passed to Symfony\Component\HttpFoundation\Response::setContent() must be of the type string or null, object given
- Target class [HomeController] does not exist
- Pass variable from blade to controller Laravel
- How to get id of next record in laravel
- RuntimeException You must enable the openssl extension in your php.ini to load information from https://repo.packagist.org
- Validation errors for multiple forms on same page Laravel
- How to get user information using hootlex/laravel-friendships package in laravel
- How to check email is valid or not in Laravel
- Display message with session flash using bootstrap alert class in laravel
- How to get CSRF token in laravel controller
- How to upload image in laravel 8
- How to get path from current URL in Laravel
- Extract only time from datetime in laravel
- How to create laravel project using composer
- Create record with unique slug in laravel
- Class 'App\Rules\Hash' not found in Laravel
- Display data in table using foreach in Laravel