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 8348817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:48:13+00:00 2026-06-09T07:48:13+00:00

We are having performance issues with that code.It works in loop with 150 times.

  • 0

We are having performance issues with that code.It works in loop with 150 times.

That code work for betting, matches have empty bet fields on screen.Then that code works for fill winner odds with looking and comparing scores.

In example, if match finished with 1-0 home team win, i must write “MS1” on screen.And for making that, i must get score info using jQuery attr selector.

In the weekends, there are a lot of matches and it is crashing or it works too slow :/

Have you any ideas to work faster?

OddEngine = function(odd)
{
    $("#matchCode_" + odd.ID).html(odd.C);
    $("#match_" + odd.ID).attr("code",odd.C);
    var status = $("#match_" + odd.ID).attr("status");
    if (status == 1)
        return;

    var htscore = $("#othomeTeamScore_"+odd.ID).html();
    var atscore = $("#otawayTeamScore_"+odd.ID).html();
    var iy_htscore = $("#homeTeamHalfScore_"+odd.ID).html();
    var iy_atscore = $("#awayTeamHalfScore_"+odd.ID).html();



    for (var i = 0; i < odd.Odds.length; i++) {
        var bet = odd.Odds[i];

         var winnerMsOdd = 'F.X';
          var winnerMsTitle =  'X';
          if (htscore > atscore)
          {
            winnerMsOdd = 'F.1';
            winnerMsTitle = '1';
          }
          else if (htscore < atscore)
          {
            winnerMsOdd = 'F.2';
            winnerMsTitle = '2';
          }

          $("#match_"+odd.ID+" [oddcode='MS']").html(bet[winnerMsOdd]);
          $("#match_"+odd.ID+" [oddtag='MS']").fadeIn();
          $("#match_"+odd.ID+" [oddtag='MS']").html(winnerMsTitle);


          if (currentSportId != 3)
          {
                var winnerIyOdd = 'S.X';
                var winnerIyTitle =  'X';
                if (iy_htscore > iy_atscore)
                {
                    winnerIyOdd = 'S.1';
                    winnerIyTitle = '1';
                }
                else if (iy_htscore < iy_atscore)
                {
                    winnerIyOdd = 'S.2';
                    winnerIyTitle = '2';
                }

                if (bet[winnerIyOdd])
                {
                    $("#match_"+odd.ID+" [oddcode='IY']").html(bet[winnerIyOdd]);
                    $("#match_"+odd.ID+" [oddtag='IY']").fadeIn();
                    $("#match_"+odd.ID+" [oddtag='IY']").html(winnerIyTitle);
                }

          }

          if (currentSportId == 1)
          {
                var winnerAuOdd = 'UNDER';
                if (parseInt(htscore) + parseInt(atscore) > 2.5)
                {
                winnerAuOdd = 'OVER';
                }

                if (bet[winnerAuOdd])
                {
                    $("#match_"+odd.ID+" [oddcode='AU']").html(bet[winnerAuOdd]);
                    $("#match_"+odd.ID+" [oddtag='AU']").fadeIn();
                    $("#match_"+odd.ID+" [oddtag='AU']").html(winnerAuOdd == 'UNDER' ? 'ALT' : 'ÜST');

                }

                var winnerTGOdd = 'GS.01';
                var winnerTGtitle = "0-1";
                if (parseInt(htscore) + parseInt(atscore) > 1 && parseInt(htscore) + parseInt(atscore) < 4)
                {
                    winnerTGOdd = 'GS.23';
                    winnerTGtitle = "2-3";
                }
                else if (parseInt(htscore) + parseInt(atscore) > 3 && parseInt(htscore) + parseInt(atscore) < 7)
                {
                    winnerTGOdd = 'GS.46';
                    winnerTGtitle = "4-6";
                }
                else if (parseInt(htscore) + parseInt(atscore) >= 7)
                {
                    winnerTGOdd = 'GS.7P';
                    winnerTGtitle = "7+";
                }


                if (bet[winnerTGOdd])
                {
                    $("#match_"+odd.ID+" [oddcode='TG']").html(bet[winnerTGOdd]);
                    $("#match_"+odd.ID+" [oddtag='TG']").fadeIn();

                    $("#match_"+odd.ID+" [oddtag='TG']").html(winnerTGtitle);
                }
          }
    }

    $("#msOdd_" + odd.ID).html(odd.C);
    if (currentSportId == 1 || currentSportId == 2 || currentSportId == 7)
    {
        $("#htOdd_" + odd.ID).html(odd.Odds["F.1"]);
    }
    $("#uOdd_"  + odd.ID).html(odd.C);
    $("#tOdd_"  + odd.ID).html(odd.C);




}
  • 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-09T07:48:15+00:00Added an answer on June 9, 2026 at 7:48 am

    There’s a lot of bad stuff in there:

    Issues:

    • You are hammering away at the DOM repeatedly. This is unavoidable but you don’t need to do as much as you are doing. A lot of the remaining points follow-up on how to avoid.

    • You’re using attribute selectors. These are slow and don’t have native methods to support in most non-XML scenarios so are going to force a lot more work out of the interpreter. Try as classes instead. You can have multiple classes and add/remove with jQuery addClass and removeClass functions without interfering with other classes. If you’re supporting IE8, narrow down to nearest ID and use a tag selector with a class.

    • You’re not caching any of your JQ selectors. $(‘#someId’) does a bit of work (although is faster than just about anything else. If it’s going to get re-used, assign to a var. Convention is: var $someId = $('#someId'); so you know it’s a jqObject. This repeatedly: $('#someId <other stuff>) is probably slower than this: $someId.find(<otherstuff>) repeatedly. In your case, assuming odd.id is unique, you’d at least want: var $matchHtml = $("#matchCode_" + odd.ID) at the top of the loop.

    • You’re doing a ton of UI stuff as you go. Consider building the collections you need and then handling it all at once after the loop. e.g. building two JQ objects for AU and TG (see the ‘add’ method) and then hitting them with the functionality they need once the loop is complete.

    • This is probably less of a big deal than the JQ stuff but you’re using a lot of ‘.’ operators unnecessarily. Every ‘.’ does actually represent some work and in some cases actually represent getters like length which can do a fair bit more work since they have to count up the array elements. Here’s the hyper-anal loop which also has the nice side-effect of being more concise:

    var myOdds = odd.Odds,
    i=myOdds.length;
    
    //if order matters, this goes backwards. Easy fix: myOdds.reverse
    
    while(i--){
        thisOdds = myOdds[i];//if you're using thisOdds more than once
        //do stuff here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some performance issues calling CGContextDrawLayerAtPoint in iOS 4 that didn't seem to
thanks for reading. I'm having performance issues with a script I've written that performs
I am having performance issues with this LINQ Query. The data is laoded into
I am having performance issues in IE and using the browser profiler, I narrowed
Our software is deployed at a client site where they are having performance issues,
I'm writing a plug-in for another program in C#.NET, and am having performance issues
I'm having a major performance issue with LINQ2SQL and transactions. My code does the
I recall having read somewhere that it is better (in terms of performance) to
I have a file log that I would like to parse and am having
I'm running into performance issues with Django because of m2m relationships. I have a

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.