Thinking about the concept of HTML 5 and modern web standards we have that in a web page, the HTML file should provide the structure, the CSS style file should provide the formatting and the Javascript should provide the behavior of the page. >
Looking at this, how should we split our javascript code? One file for each page, one "archive" with all the events and methods of all the pages?
Should we have a .html
and a .js
separated file for each webpage?
What is your recommendation?
[UPDATE QUESTION 3/5/2014]
I understand that it is not a question that will have a right or wrong but my goal is to collect the largest number of different opinions and make my conclusions based on the comments and responses of colleagues.
In order to respond, some will consider code reusability, others will consider performance, other maintenance, etc.
My question is not about using existing JS frameworks but my own routines.
For example, let's say I have a page that has a combobox and I want it to select a value something happens on the page, either manipulate other objects via the DOM or perform some remote operation with Ajax. Somewhere on my page I will have a javascript to perform this. My question then applies: For this type of javascript code, I create one file per page, I leave JS in the html file (cshtml, php, whatever) or I put all those small routines in a single js and link to all pages, or any other variation thereof.
I find a valid discussion that can add value to many.
What do you recommend?