Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6343029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:21:24+00:00 2026-05-24T20:21:24+00:00

This is a design question. I find myself going back and forth between two

  • 0

This is a design question. I find myself going back and forth between two UI design styles.

The UI on a prototype I developed recently relied heavily on loading the elements of the UI as partial views via AJAX. I did not like that approach because I had to do a lot of requests to the server while my page was loading. However, the plus of this design was that I could easily edit the partial view templates, so the code was easier to manage.

In the next iteration I decided to package all the information at once and then use JavaScript to generate partial views and plug this information into it (and only use Ajax when on-demand up-to-date information was actually needed). My page loads faster, but I find myself generating a lot of HTML snippets in JavaScript, which is getting harder to manage.

As I see it, using Ajax you get:

  • Easier to maintain (+)
  • Longer UI response times (-)

And with JavaScript only, you get

  • Faster UI response (+)
  • Easier to handle server-side errors (+)
  • Harder to maintain (-)

So, There are a few things on which I would like to hear your comments:

  1. I do not like using Ajax unless I don’t have a need for actual on-demand data. Am I wrong?

  2. Are there frameworks/libraries that would make managing HTML-generating JavaScript code easier?

  3. Are there any other pros/cons of the two approaches that I have missed?

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:21:25+00:00Added an answer on May 24, 2026 at 8:21 pm

    There are templating libraries for JavaScript, if you want to get that involved. In general I would avoid manually sticking together HTML strings from JS unless there’s a particular need to (eg in some cases for performance when dealing with very large tables).

    HTML-hacking is difficult to read and prone to HTML-injection security holes when you don’t get escaping right.

    Start instead with the DOM methods, and use DOM-like content manipulation libraries to make it easier. For example, if using jQuery, do this:

    $('<a>', {href: somelink, text: sometext})
    

    and not this:

    $('<a href="'+somelink+'">'+sometext+'</a>')  // insecure mess
    

    There doesn’t need to be a big difference between fetching data through XMLHttpRequest vs including it in the HTML document itself. You can direct a bunch of JSON data to the same function that will build page parts whether it was just fetched by XMLHttpRequest in an update operation, or included in function calls at document load time.

    When including data in the page you will generally need to include a timestamp they were generated in any case, so that if the browser goes back to the page a while later without reloading it, the browser can detect that the information is now out-of-date, and cue up an XMLHttpRequest to update it.

    The usual question when you’re creating your page content from data with client-side JavaScript is, are you going to fill in the initial static HTML version from the server too? If so, you’re going to be duplicating a lot of your content generation work in both client-side JS and the server-side language(*). If not, then you’re making the content invisible to non-JS user agents which includes search engines. Whether or not that matters to you typically depends on what the app is doing (ie does it need to be searchable and accessible?)

    (*: unless you can use server-side JavaScript from something like node.js and re-use your content generation code. This is still a somewhat rare approach.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a design question. I'm trying to decide between 2 implementations. In order
This is a design question and good practice question. How do you structure your
This is a design question: when do I need to create/use a static method
This is a design question, I noticed that by time by LINQ-to-SQL Context gets
I've been thinking about this object oriented design question for a while now and
This is a practical Domain Driven Design question: Conceptually, I think I get Aggregate
This should be a very basic design question, but for some reason it doesn't
This question is more UI/Design-ish than hard-core programming is. Background: I've been coding in
This is a question about generic c++ event driven applications design. Lets assume that
Update: Please read this question in the context of design principles, elegance, expression of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.