Comments (4)
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.
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.
Great stuff!
In lemonReady
, I think let item = items.length[ i ];
should be let item = items[ i ];
from aristath.github.com.
@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)
- Comments: What is the meaning of all this? HOT 4
- Comments: The Gutenberg Layout Problem HOT 1
- Comments: Pay it Forward Pledge HOT 4
- Comments: Thoughts on a Sustainable Web
- Comments: How to only print styles for Gutenberg Blocks used on a page HOT 9
- Comments: Hijacking the wp.customize set & get methods for settings
- Comments: A new comments system for my static Jekyll site HOT 65
- Comments: Styling Links
- Comments: Fluid Typography with CSS Variables HOT 1
- Comments: Typography Scales with CSS Variables
- Comments: The Hidden Color Functions in WordPress
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aristath.github.com.