theintersect
theintersect

Reputation: 758

One single page manipulation vs multiple html files

I have a basic javascript question. In terms of performance, security, maintainability, which would be better. To maintain one script file, with multiple javascript files, and creating a framework that would manipulate the interface.

For example I have an index.html, that loads multiple js files. Then depending on what actions are done, the page is manipulated.

Or is it better to create and maintain multiple html files? Index.html, login.html, etc.

Thank you.

**EDIT

to be more detailed, lets say I have an index.php, it loads multiple javascript files, and provides the basic layout of the page. Then depending on what action the user selects, the page doesn't load, instead, it creates an ajax request, then if it has to, manipulate the DOM, then display the data where needed.

Upvotes: 1

Views: 1084

Answers (2)

Anthony
Anthony

Reputation: 2411

It seems like you are trying to create a one page user experience that utilizes multiple views (html files), by calling their content and manipulating the dom based upon user input/actions.

If you are concerned with maintainability and performance separating out your presentational elements into separate files and then loading those files into your current view is the most efficient way of handling this functionality in both respects. For instance, if a user is automatically logged in after they have logged in an initial time, loading the markup for the login form with your singular page would be a waste. Additionally, if there is other content that may or may not be utilized by each user each time your application is used, the same logic applies.

From a security standpoint, I do not see a major difference between the two options (1 page vs multiple pages) depending upon what kind of information you are passing to the client. Regardless ajax calls can be handled in a secure way, as long as you are not sending any secure data asynchronously back and forth from client to server.

Upvotes: 1

tigretigre
tigretigre

Reputation: 46

It is much easier and reliable to maintain separate html(?) files, especially since javascript support is inconsistent. If there are common elements to the HTML, some sort of templating system is desirable. Your server gets less traffic if changes are made client-side with JavaScript, but if there are complicate operations it could be a drag on the client's CPU so it might not be worth any server-side gains.

Upvotes: 1

Related Questions