Web Analytics Made Easy -
StatCounter Client Side Javascript: Is it efficient to...? - CodingForum

Announcement

Collapse
No announcement yet.

Client Side Javascript: Is it efficient to...?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Client Side Javascript: Is it efficient to...?

    Hey guys. I have some intermediate experience with basic JavaScript but to be honest I've usually been more of a server side scripting kind of guy. I'd really appreciate some input from those of you with more advanced experience.

    Iately I've been working as a code developer with a another website designer. We're trying to separate code from design (logic from GUI) and in a lot of ways it's worked pretty well. He'll design a page & identify key elements, say a form field, with an ID. My server side code will then output JavaScript that references the field by ID or by name and sets the value.

    My question is, I'd really like to have a way to separate code from display for other types of pages also, say a message board or a photo gallery. This seems like an awful lot of client side processing though. Is JavaScript efficient enough to tackle something like that? I mean the JS itself may be as simple as:

    document.getElementById('message_board_div').innerHTML="long string of text output by server side code that contains all the table layouts & content for the entire section of the page...";

    Is this just too risky on a computer with a slow processor? I'm pretty used to JS syntax but not all the ins & outs of its strengths & weaknesses.

    Thanks for any input.
    Cliff

  • #2
    it depends on the amount of data which you want to manipulate in a single sesion. If it is resonable, it is easier to use server-side includes or server-side requests onload to build at client level data (for instance a javascript array), and then let javascript codes to handle locally set data.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

    Comment


    • #3
      I'm not sure I understand exactly what you're saying but I'll take it that my concern over the ammount of data JS can handle is somewhat valid. What I was basically hoping to do was something like this:

      <body>
      <!-- Whatever HTML code here for page layout -->

      <div id="discussion_content">Loading Discussion...</div>

      <!-- Whatever HTML code here for page layout -->
      </body>

      <!--#include virtual="display_discussion.asp"-->

      --------------------------------------------------------------------------------
      Then in display_discussion.asp, I would output something like...
      --------------------------------------------------------------------------------

      <script type="text/javascript">
      var output;
      output = output + '<table><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr><tr><td>Post content...</td></tr></table>';

      // no idea how long the above string might end up being as people may post very long replies to discussions.


      document.getElementById('discussion_content').InnerHTML = output;
      </script>
      --------------------------

      Is that too much to expect of JavaScript?

      Comment

      Working...
      X