Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4880

zjq.clearStyles performance

XMLWordPrintable

      Steps to Reproduce

      https://zkfiddle.org/sample/3okm2g5/1-update-styles-performance
      click anywhere on the screen

      Current Result

      it takes 4.3sec (with profiler enabled) to update the inline styles
      most of the time is spent clearing the old styles (inefficiently)

      Expected Result

      evaluate whether this can be improved

      Debug Information

      https://github.com/zkoss/zk/blob/2c7ebc163661fd0e7f349da743190458ad089a07/zk/src/archive/web/js/zk/dom.ts#L1974-L1981

      the inner loop is iterating over each possible CSS attribute (using for...in) mostly doing nothing

      clearing the existing inline styles might be done as shown in the workraround

      Workaround

      removes the clearStyles overhead almost completely (however there might be a reason for the previous, more complex implementation)

      zjq.prototype.clearStyles = function() {
         this.jq[0].style.cssText = null; 
         return this;
      }
      

            DevChu DevChu
            cor3000 cor3000
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: