Thanks!  I appreciate the time you spent on figuring out what was
going on and giving me feedback.  The last part, where you talk about
getting elements by ID, might be kind of hard because the ID ends in
Panel1 if it's textbox, Panel2 for radio buttons and Panel3 for
checkboxes.

RC is how I distinguish in script that these items are either a radio
button or checkbox...RCRB is a radiobutton, RCCB is a checkbox.

Again, I really appreciate your help.  I am going to create a copy of
my files and take your optimization techniques and rewrite the code.
I'll let you know how it goes.



-TJ



On Jul 30, 1:03 am, Ricardo <ricardob...@gmail.com> wrote:
> Pardon the words, but that's a s***load of processing being done in
> your JS, and a huge DOM! Most of the class adding, appending and CSS
> should really be done server-side. Some tips to improve your script's
> efficiency:
>
> #1
> You get all elements with class^=RC, then get their classnames one by
> one, then lookup the classnames one by one again... absolutely no need
> for this loop. the var 'divs' already contains all the elements you
> want. uniqueArray is not required. The first 40 lines of your script
> could be replaced by this:
>
> http://snipt.org/lQh
>
> But for a really great improvement, you should consider adding a
> separate "RC" class to all the relevant elements:
>
> <div id="QuestionnaireLV_ctrl22_Panel2">
>   <div class='RC RCRBAFilingType' qid='22'>
>      <span...><br />
>      <input.../>
>   </div>
> </div>
>
> So your javascript would be way shorter, simpler and faster (native
> getElementsByClassName is blazing fast):
>
> $('.RC').wrap('<div class="RCWrap"></div>');
>
> and the styles could be added via CSS:
>
> .RCWrap {
>    display: inline-block,}
>
> .RC {
>    display: inline-block,
>    width: 150px}
>
> .RC span {
>    display: block,
>    width: 300px
>
> }
>
> #2
> in the groupThis function, consider getting the elements by their IDs
> instead of the "qid" attribute, native getElementsByID is also way
> faster:
>
> function groupThis(start, end) {
>    var selector = "";
>    for (var i = start; i <= end; i++) {
>       selector += "#QuestionnaireLV_ctrl";
>       selector += i;
>       selector += "_Panel1"
>       if (i < end)
>          selector += ",";
>    }
>    return selector;
>
> }
>
> Avoiding string concatenation ("#Que.." + i + "_Panel") also gives you
> a speed up. As a bonus of selecting by the IDs you avoid the dozens of
> parent() calls later on.
>
> These two changes should already significantly improve your script's
> run time.
>
> cheers
> -- ricardo
>
> On Jul 28, 9:18 pm, TJ <alyssamar...@gmail.com> wrote:
>
> > This error message occurs on slower computers...I haven't had it
> > happen on my 2 home computers.  But I see that there is a potential
> > problem for a number of people.
>
> > On Jul 28, 6:12 pm, TJ <alyssamar...@gmail.com> wrote:
>
> > > Thank you for your quick response.
>
> > > Here is a link to the page in question:  http://docfiller.com/process.aspx
>
> > > The error when using the jQuery min file is line 19 and when using the
> > > full jQuery (uncompressed) file, it is around 1988 - 2040, it varies.
> > > It also varies on what iteration in processing the error occurs.
>
> > > I appreciate any assistance you can give.
>
> > > -TJ
>
> > > On Jul 28, 5:25 pm, "Michael Geary" <m...@mg.to> wrote:
>
> > > > There's no set limit on the number of selectors you can use, but as 
> > > > you've
> > > > seen, selectors can take some time to run and eventually the browser 
> > > > will
> > > > time out.
>
> > > > There's really nothing more that can be said without seeing your code. 
> > > > Can
> > > > you post a link to the failing test page?
>
> > > > -Mike
>
> > > > > From: TJ
>
> > > > > Hello,
>
> > > > > I keep getting thisUnresponsiveJavascript error.  I will
> > > > > admit I have a ton of selectors and code going on.  When I
> > > > > use FireBug to debug that message, it stops somewhere within
> > > > > the Sizzle CSS Selector part of jQuery.  Different spots and
> > > > > at different iterations in myscript.
>
> > > > > I have tried going back to jQuery 1.2.6 too, I saw some
> > > > > people said that helped and using the full (uncompressed)
> > > > > version too.  Neither worked for me.
>
> > > > > Soon after the warning message, if you click continue, it
> > > > > loads the rest of the javascript and the page.  It seems like
> > > > > I may have just a few too many selector calls?  When I
> > > > > comment out about 20 lines I don't get the message, but I
> > > > > need those 20 lines.
>
> > > > > Does jQuery have a limit to how many selections it can do within the $
> > > > > (document).ready(function() { ?

Reply via email to