Include External CSS and JS file in Laravel

Created at 11-Oct-2022 , By samar

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:

    1. create subfolders named css and js in public folder.
    2. Place style.css file in CSS folder.
    3. Place custom.js file in js directory.
    4. Open blade file.
    5. 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>
    

Back to code snippet queries related laravel

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

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.