A
A
Abc Edc2015-08-07 08:19:21
JavaScript
Abc Edc, 2015-08-07 08:19:21

Organization of laravel and js code, what are the best practices?

Is it possible to organize one view and js according to it (for example /news index.blade.php ... /widgets news.js news.blabla.js etc.) to load only certain js on certain pages. Or should everything be stored in index ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
OnYourLips, 2015-08-07
@gleber1

If JS is used in only one site module, then it is normal that it is included in the views only in it, and not in the index.

M
Merk47, 2019-03-13
@Merk47

Alternatively, you can use the @stack('scripts') blade directive to collect both <script src="">in the footer area for connecting scripts, and inline js pieces to collect in a common party line somewhere at the end of the page (will not be cached by the browser (!) ).
Or use webpack / elixir bundles to connect different bundles, consisting of a different set of components in different application modules.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question