jQWidgets Forums

jQuery UI Widgets Forums Lists ListBox Needless setInterval?

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 12 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Needless setInterval? #6373

    pk
    Participant

    Background: I was monitoring my app for performance, and I noticed that even though I would let the window idle and unfocused, I’d have 6-10% of my CPU occupied by firefox. So I run the profiler in firebug and noticed this:
    […]
    _addHandlers: function () {
    var k = this;
    this.focused = false;
    var l = false;
    var h = 0;
    var d = null;
    var h = 0;
    var b = 0;
    var f = new Date();
    var c = this.isTouchDevice();
    if ((this.width != null && this.width.toString().indexOf("%") != -1) || (this.height != null && this.height.toString().indexOf("%") != -1)) {
    this.autoUpdateId = setInterval(function () {
    if (k.host.height() != k._oldheight || k.host.width() != k._oldwidth) {
    k._oldwidth = k.host.width();
    k._oldheight = k.host.height();
    if (k.items) {
    if (k.items.length > 0 && k.virtualItemsCount * k.items[0].height < k._oldheight) {
    k._render(false)
    } else {
    k._updatescrollbars();
    k._renderItems()
    }
    }
    }
    }, 100)
    }

    […]
    The question is, does this piece of code serve any purpose that I’m not aware of? Should I remove it completely, or set the timeout to some other value? An interval of 100ms is too much performance degrading I think.

    Needless setInterval? #6374

    Peter Stoev
    Keymaster

    Hi pk,

    As you can see, the code is executed when the size of the widget is in percentages and the size is changed. The code will update the size of the elements, if the widget’s size is changed. However, thanks for the feedback! We’ll consider making improvements in the next version.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.