10 Replies Latest reply on Jul 11, 2017 4:41 AM by Eli-zabelle

    What makes a form slow?

    Eli-zabelle Level 1

      Hi,

      I have a document with 120 similar text fields + 20 dropdowns. There is mainly two simple action Javascript  + 1 format script per field. I have a button to reset all fields and it takes up to 20 seconds on a regular performing computer. The action scripts weren't absolutely essential so I've tested the document without them, but nothing changed in the time it took to reset.  Also, when I open the document, it takes quite a while for all the fields to appear.

       

      What are the reasons that can make a document so very slow? Do I have too many fields? Are there other reasons that maybe I could correct? Thank you.

       

      I have Adobe Acrobat Pro DC.

        • 1. Re: What makes a form slow?
          Joel_Geraci Adobe Community Professional

          You haven't posted the for so this is only a guess but I'll bet the code isn't optimized and there are a ton of string literals in it.

           

          Add the line...

           

          this.delay = true;

           

          ... at the top of your reset script and then.

           

          this.delay = false;

           

          ... at the end of your reset script.

           

          This will stop the form from redrawing the fields as it's being reset. That may give you a performance boost.

          • 2. Re: What makes a form slow?
            Eli-zabelle Level 1

            Hi Joel,

            On my reset button properties, I used the command Reset form and checked the fields I wanted to reset.

             

             

            Now, to use what you suggested, I wrote a script instead of the command using this.resetForm with each of the seven parent fields.

             

            Example :

             

            this.delay = true;

             

            var a= this.getField("Ville4L");

            this.resetForm(a);

             

            this.delay=false;

             

             

            Is this how I'm suppose to write it? Because it did reset my form, but took even much longer!

             

            thanks.

            • 3. Re: What makes a form slow?
              Joel_Geraci Adobe Community Professional

              Did you want to reset the form or just a few fields?

              • 4. Re: What makes a form slow?
                Eli-zabelle Level 1

                Initially, I had pretty much all the fields checked on the reset command. I only unchecked a few fields that were static and had no special function, in case it would help.

                • 5. Re: What makes a form slow?
                  Joel_Geraci Adobe Community Professional

                  Ok - then my guess is that there's something very inefficient in the JavaScript in the fields. I can't diagnose that without the form though.

                  • 6. Re: What makes a form slow?
                    Eli-zabelle Level 1

                    In almost every field, I have them three script

                     

                    Under action tab :

                    • On mouse down :
                      var f = this.getField("Ville4L.0.0"); //get the text field
                      if (f.value == f.defaultValue) f.value = ""; //if field value = the default, then clear it

                     

                    • On deactivate field (?english) :
                      var f = this.getField("Ville4L.0.0"); //get the text field
                      if (f.value == "") f.value = f.defaultValue; //if field value = empty, then restore the default

                     

                     

                    Under format tab :

                    • Custom format :
                      // If field is blank, do not print this field 
                      event.target.display = event.value ? display.visible : display.noPrint; 

                      // If field is blank, display this text 
                      if (!event.value) event.value = "Ville", event.target.textColor = color.gray;
                      else
                      event.value = event.value.toUpperCase(), event.target.textColor = color.black;

                     

                     

                    It all works perfectly to clear default value as we click on field, and format in capitals what is entered as we leave. The form is great for the simple task I want it to do.  But is this too heavy that it causes all the delay?

                     

                    I made a test by erasing the first two scripts and leaving only the uppercase &black text color under custom format, and saw no improvement in the lag.

                     

                    Thanks!

                    • 7. Re: What makes a form slow?
                      Joel_Geraci Adobe Community Professional

                      Try combining the two settings into one if statement. Modify the value first, then set the display property.

                      • 8. Re: What makes a form slow?
                        Eli-zabelle Level 1

                        Are you talking about the two scripts under the action tab? How do I do this when the first if statement is on focus and the second is on blur?

                         

                        Thanks!

                        • 9. Re: What makes a form slow?
                          Bernd Alheit Adobe Community Professional & MVP

                          Eli-zabelle  wrote

                           

                          In almost every field, I have them three script

                           

                          Under action tab :

                          • On mouse down :
                            var f = this.getField("Ville4L.0.0"); //get the text field
                            if (f.value == f.defaultValue) f.value = ""; //if field value = the default, then clear it

                           

                          • On deactivate field (?english) :
                            var f = this.getField("Ville4L.0.0"); //get the text field
                            if (f.value == "") f.value = f.defaultValue; //if field value = empty, then restore the default

                           

                          ...

                          At almost every field you change the field "Ville4L.0.0" ?

                          • 10. Re: What makes a form slow?
                            Eli-zabelle Level 1

                            Yes. I could have worked with just event.value as I now see. Maybe I had tried at first and something didn't work quite right. I will make the changes, it might make a difference.