R
R
rustem_ck2015-09-21 17:48:51
JavaScript
rustem_ck, 2015-09-21 17:48:51

How to include (architecturally use) JS code in a laravel 5.1 project?

Are there any recommendations or best practices for using JS code in a project?
For example, there is a laravel 5.1 project that uses JQuery. Each page uses js-actions, one or another UI element. (click, ajax, etc...).
Now there is a common core.js - a file that is connected and executed on each page.
I do not like:

  • In one file, all the code for all pages, even if the page is not the same, the element processing code is present

I would like for each separate page of the blade template to have a js file of the same name. Is it correct?
Who uses it and how?
I will be glad to any articles and examples of building an application architecture using JS code.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2015-09-21
@alexey-m-ukolov

The standard practice is 1 file with all common libraries, 1 file with the general code of a section (a directory, for example) and 1 file with a specific page code.
This allows you to flexibly manage caching and not load too much.
There may not be a file for the page if all standard elements are initialized in the section code.

A
Alexander Alexandrovich, 2015-10-18
@tatu

Try https://github.com/tabuna/ui-load
Allows you to load on the page only what is needed, be it js or css.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question