Home >Web Front-end >HTML Tutorial >Is it reasonable to develop a website to create a js file for each page? What is reasonable? _html/css_WEB-ITnose

Is it reasonable to develop a website to create a js file for each page? What is reasonable? _html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:11:271206browse

Is it reasonable to develop a website and create a js file for each page? What is reasonable?


Reply to discussion (solution)

Why is it unreasonable? . . When using the same method, write it to a file. .

The common function is to write the style into a file and just link or include it when applying.

The same JS code for each page is written in a JS file, and each page can be connected to this JS file.
The setting method is the same as the CSS file.

The common method can be written in a js file, and it can be called on every page used.
Basically, sometimes for optimization, all the js used are written in one file.
Of course, the js that is directly executed when parsing each page still needs to be written separately. This can be written as a js file or written directly in the page if necessary

If you don’t have many pages If so, just write and package the head, tail, or middle parts of the web page independently and call it on the required page. If you want to change it, it is also convenient

Reducing the number of js can reduce requests.
Reasonable is relative

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn