Javascript performance between thin client and PC

I have a web application using thin clients (bosanova terminals) as an interface for users. I noticed some performance differences in JavaScript between the thin client and the PC. Terminals run Windows XP, built into IE6, and the pages I link to use a prototype JS structure to perform a fairly simple form element validation.

for example, the following that I use to make sure the required fields are filled.
To do this, there are two more .numeric and .alaphanumeric that check and push errors to stop form submission.

$$( '.requiredfield' ).each( function ( elem ){
   if ( ( $( elem ).value.length == 0 ) || ( $( elem ).value == null ) ) {
        $( elem ).addClassName( "nonvalid" );
        $( elem ).siblings().first().addClassName( "error" );
        requiredErrors.push( $( elem ) );
   }

});

The problem I see is a PC in Firefox or IE, a form with 5-20 fields per page takes perhaps half a second to process longer than without validation. However, it takes 15-25 seconds longer on the terminal to complete a check, except for the same page, without it. As far as I think, I mentioned that I tested this in IE6 on a PC and I don’t see any performance loss. The call to Bosanova led me to update the memory in the terminal, which I did just before this publication, and the results did not change.

I can change the script, so I go through the form fields only once and process .required.numeric.alphanumeric when I go, and that will help, I'm sure. As of now, there is such a difference in performance between the PC and the terminal (thin client). I am curious to know why.

- , /javascript , .

: → → → → → → → → >

, , . , . IE6 , . , , , 1. IE6 2. , 10-50- , . - , 1,2- () 1,6- () , HD/DOM 512 () 1gig (). - , , , / .

: → → → → → → → → >

+3
2

Prototype, , $.

$$( '.requiredfield' ).each( function ( elem ){
   var el = $(elem)
   if ( (elem.value.length == 0 ) || elem.value == null ) ) { // is elem.value ever null?
        el.addClassName( "nonvalid" );
        el.siblings().first().addClassName( "error" );
        requiredErrors.push(el);
   }
});

, , , , , . , , / , .

, - (-, , - ):

var errors = {};

var rules = { 
   ".required": function (elem) { return elem.value.length == 0; },
   ".alphanumeric": function (elem) { return /[a-zA-Z0-9]+/.test(elem.value);  }
};

$$( "input", "#your_form_id" ).each(function ( elem ) {
   var el = $(elem)
   var classes = (function () { 
      var cls = elem.className.split(' '), classMap = {};
      for (var k in cls) classMap[cls[k]] = true;
      return classMap;
   })(); // get the classes for this element

   for ( var rule in rules ) {
       error[rule] = [];
       if ( rule in classes && !rules[rule](elem) ) {
          el.addClassName("nonvalid");
          el.siblings().first().addClassName("error");
          errors[rule].push(el);
       }
   }

});

errors.. , , errors["required"], .

0

, IE6 Javascript — , , Microsoft , Web , , ActiveX. , , CPU .

, :

$$( 'input.requiredfield' ).each( function ( elem ){
+2

Source: https://habr.com/ru/post/1757740/


All Articles