I'm writing a Laravel 5.3 app using it's default layout, and I'm wondering which is the best practice for adding an external js library.
Should I have to put the js file directly in public/js, or there is another cleaner way to do it?
我通常在public / js中添加我的外部库,比如jQuery,因为在我的视图布局中使用它更自然,因为Laravel隐式引用了这些资产的公共目录。
One way to do this is-
Directory structure
Public
|
|-js
|-script.js
|-css
|-style.css
To call libraries call asset()
helper
<script src="{{ asset('/js/script.js') }}"></script>
I also put everything is the public directory public/js etc, but sometimes I create sub directories to keep thing easy and orderly. Then you can call
asset('js/widgets/mywidget.js').
I do a similar thing with css and siteicons.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.