Further Speed Optimisation #21

Open
wants to merge 3 commits into
from

3 participants

@vzwick

By pre-caching of $(settings.container) and default_container flag

Valentin Zwick added some commits Jan 29, 2012
Valentin Zwick Further Speed optimisation
By pre-caching of $(settings.container) and default_container flag
0b4b387
Valentin Zwick Further Speed optimisation
By pre-caching of $(settings.container) and default_container flag
2784ba3
@vzwick

The pre-caching should make things significantly faster when using a custom container.

@tuupola
Owner

Thanks. Will merge during weekend.

@tuupola
Owner

Merged half of this. Thanks! Will keep pull request open to remind myself to merge rest of it after I do some internal changes.

Valentin Zwick My usual two cents performance – albeit this is only a comment ;) One…
… should avoid using jQuery proprietary selector extensions for performance reasons (thus enabling the use of native selector implementations by jQuery in the background) and use `filter()` instead.
0f908df
@vzwick

Err. Disregard the update, please.

@regisf

New update function to improve speed. It's not the jquery way of life, but it's faster. The loop is descending because JIT compiled scripts run faster. Works on FF, Chrome. Not tested with IE.

    function update() {
        var counter = 0;
        for(var i=elements.length - 1; i >= 0; i--) {
            var el = elements[i], $this = $(el);
            if ($this.data('ll_loaded') === true) {
                continue;
            } else if (settings.skip_invisible && !$this.is(':visible')) {
                continue;
            } else if (!$.belowthefold(el, settings) && !$.rightoffold(el, settings)) {
                    $this.trigger("appear");
                    $this.data('ll_loaded', true);
            } else {
                if (++counter > settings.failure_limit) { // Don't know what to do here but it's work.
                    //break;
                    continue
                }
            }
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment