Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

496
Views
Laravel 9: Where to place common javascript file?

In my Laravel 9 project that I am working on, I want to put a javascript file containing common functions in app.blade.php. As per How to include External CSS and JS file in Laravel 5.5, I placed the js file in public/js folder and included the following in app.blade.php

 <!-- common js functions added by Ravi  -->
<script src="{{ asset('js/common_js.js') }}" ></script>

However, this file is not getting included on the page, and the js functions included in the file are not available in console.

Could someone advise me how to include a js file so that it is available for all pages?

Thanks.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

if you are using laravel vue do this

place th common_js.js file in resources folder than change this

//in webpack.mix.js
mix.js(["resources/js/app.js","resources/js/common_js.js"], "public/js")

and in app.blade.php use this

<script src="{{ mix('js/app.js') }}" defer></script>

than

npm run dev
about 4 years ago · Juan Pablo Isaza Report

0

run command

php artisan view:clear
about 4 years ago · Juan Pablo Isaza Report

0

you need to check the path rendered by asset() if it's not the correct path you can change the asset path from the .env file ASSET_URL

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!