Php writes a web project to write a web project. Is it better to put JavaScript in a single js file, or to directly write it in an html page? What are the advantages and disadvantages? Php? Js? Webhtmlphp php write web Project
When writing a web project, is it better to put JavaScript in a single js file on the page, or to directly write it in an html page? What are the advantages and disadvantages?
Php? Js? Web html php js
------ Solution --------------------
In any case, requirements always come first!
Now that you have used the path in js, you do not want to change it to a relative path.
So is it unnecessary to discuss built-in or external connection?
Of course, you can also embed an independent js file into the main template as a sub-template.
------ Solution --------------------
You can create a js file that stores specific paths. This File defines all path variables. Other js files use the path variables defined in this file. Then the js file that stores the path can be introduced before other js files.
For example, define path. js
It defines var filePath = "****";
The filePath is used as the path in other files.
When used, define in the page: