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

  • SEARCH
  • Home
  • 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 8981311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:18:17+00:00 2026-06-15T20:18:17+00:00

Question about the speed/efficiency of using jquery traversal vs adding extra flat content to

  • 0

Question about the speed/efficiency of using jquery traversal vs adding extra flat content to a page:

I have a table with a set of data where each row contains text in the first cell and then values of time for that text. I’m going to use Highcharts to allow users to view charts for the values in each row. There’s a link on each row to launch a chart within a modal popover. This table may have anywhere between a few dozen and to a few hundred rows and up to 20 columns.

The table will look something like this:

<table>
  <thead>
    <tr>
      <th>Graph</th><th>Location</th><th>Jan</th><th>Feb</th><th>Mar</th><th>Apr</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a href="#" class="view-chart">View</a></td><td>Paris</td><td>14</td><td>22</td><td>18</td><td>16</td>
    </tr>
    <tr>
      <td><a href="#" class="view-chart">View</a></td><td>London</td><td>32</td><td>24</td><td>22</td><td>27</td>
    </tr>
    ....

To get the location name and the monthly values to create a line graph, I could either use jquery to grab the values when the users clicks on .view-chart and put them in the format needed by Highcharts. Using something like this:

$('.view-chart').click(function() {
  var series = { data: [] };
  var graphTitle = $(this).parent().next().text();
  var tds = $(this).parent().next().nextAll();
  $.each(tds, function(index, item) {
    series.data.push(parseFloat(item.innerHTML));
  });
});

Or I could simply create a some sort of hidden element with all the values and then grab those on click:

<div style="display: none">
  <div id="paris">14,22,18,16</div>
  <div id="london">32,24,22,27</div>
</div>

So my question is which approach is faster/more efficient for this purpose? Should I add extra flat code to the page itself that contains all relevant data in an easy to use format? Or is it better to shorten the page and let jquery parse on click?

I imagine either will work fine, but what if the table grows to thousands of rows or hundreds of columns?

  • 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-06-15T20:18:19+00:00Added an answer on June 15, 2026 at 8:18 pm

    The best approach (I think) that you did not even think of is making .paris, .london, etc classes that you can just select on and get all of the numbers that you need.

    <tr>
      <td><a href="#" class="view-chart">View</a></td><td>Paris</td><td class='paris'>14</td><td class='paris'>22</td><td class='paris'>18</td><td class='paris'>16</td>
    </tr>
    <tr>
      <td><a href="#" class="view-chart">View</a></td><td>London</td><td class='london'>32</td><td class='london'>24</td><td class='london'>22</td><td class='london'>27</td>
    </tr>
    ....
    

    So selecting:

    var paris = $('.paris');
    var parisArray = [];
    paris.each(function(){
        parisArray.push(this.innerText);
    });
    

    Or to get all of them:

    var allElements = {};
    $('.view-chart').each(function(){
       var tableRow = $(this).parents('tr');
       var rowName = $('td', tableRow).eq(1).text().toLowerCase();
       var place = $('.' + rowName);
       var placeArray = [];
       place.each(function(){
            placeArray.push(this.innerText);
       });
       allElements[rowName] = placeArray;
    });
    

    Fiddle: http://jsfiddle.net/maniator/YJSg4/

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

Sidebar

Related Questions

I have a question about why there is such a difference in speed between
For the sake of this question, let efficiency mean, more-or-less, page rendering speed. Albeit,
I have a question about rendering speed for the css3 transition property. Suppose I
I have a question about the Bitmap class. If you want to set a
Following a question posted here about how I can increase the speed on one
Question about GridView sorting in VB.NET: I have a GridView with AutoGenerateColumns = True
I have a question about presenting the TWTweetComposerViewController as a modal view in iOS
I have been working on speeding up a query I'm using for about a
This is a very open question about a problem that we have. Basically, we
People have asked similar questions about the efficiency of various data structures but none

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.