Giter Club home page Giter Club logo

Comments (4)

aristath avatar aristath commented on June 13, 2024 1

Yes, it would be best to use getElementById when applicable for performance.
If you're not converting a jQuery script to vanilla and you don't need a simple way to just do a search-and-replace on your scripts and be done with it, then it would be recommended to use these faster methods.
However, if you want to build a drop-in replacement for jQuery custom-tailored to your own needs, then querySelectorAll is the only really viable option. And it's not slow, it's absurdly fast: https://gomakethings.com/javascript-selector-performance/

When writing something from scratch I'd definitely prefer using getElementById. But when converting a script I'd just go for the convenience of querySelectorAll 👍

from aristath.github.com.

Waldir avatar Waldir commented on June 13, 2024

Excellent article! One question, is using querySelectAll on the wrapper function the best for performance? Wouldn't using getElementById be better when applicable?

from aristath.github.com.

galbaras avatar galbaras commented on June 13, 2024

Great stuff!

In lemonReady, I think let item = items.length[ i ]; should be let item = items[ i ];

from aristath.github.com.

varunsridharan avatar varunsridharan commented on June 13, 2024

@aristath great blog. well i think i kind of found an issue.

in below code i have marked a line which i believe that some other line of code should get replaced. because i keep getting below listed error

/**
 * Get the parents based on a selector.
 *
 * @param {string} selector - The CSS selector.
 * @return {Object} - returns the _lemon object to allow chaining methods.
 */
_lemon.prototype.parents = function( selector ) {
	let found = [],
		self  = this;
    this.each( function( el ) {
--        let elFound = self.parents( selector, el );
        if ( elFound ) {
            found = found.concat( elFound );
        }
    });
	return new _lemon( found );
};
- Uncaught InternalError: too much recursion

from aristath.github.com.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.