All Questions
Tagged with jquery-selectors performance
92
questions
1
vote
0
answers
63
views
Best way to optimize a jQuery selector [duplicate]
I need select the tr of thead
$("#table > thead > tr");
Is much the difference respect to this:
$("#table").find("thead").find("tr");
Is there a way to optimize this jquery selector, what is ...
0
votes
1
answer
78
views
Will jQuery run faster if the HTML element name is added with the ID?
below is a snippet of code I use for added data to a table when a div is clicked on:
$(document).on("click", "div#pos_product_id_<?php echo $row['id']; ?>", function() {
$("table#...
1
vote
2
answers
298
views
JQuery Performance: removing class
I have JS that runs to remove a class "modified" from all descendants of a form element. Which will perform better?
$form.find('*').removeClass('modified');
or
$form.find('.modified').removeClass('...
1
vote
1
answer
46
views
Peformance of universal selector, contradicting results?
According to the official website:
The all, or universal, selector is extremely slow, except when used by itself.
So, I think this means that $("#section").find("*") should be faster than $("#...
1
vote
1
answer
55
views
Store $('body, html') selection as jQuery
I'm optimizing the JS code, and stumbled over this question:
At various places in the scripts there are jQuery selectors which select 'body, html', mostly to change/check-for a class. Now I was ...
0
votes
1
answer
313
views
What is faster/more efficient - $(".selector").height() vs $(".selector").eq(0).height()
I have 20 x element.selector with same (100px) height and I need to get their height (100px, not 2000px).
What is faster/more efficient to do?
$(".selector").height()
or
$(".selector").eq(0)....
3
votes
1
answer
2k
views
How to extend a jQuery selector that is stored in a variable?
I have a jQuery selector stored in a variable, like so:
var myVariable = $( ".js-selector" );
I'm wondering if and how I can use this variable to select children of this element, instead of writing:
...
1
vote
1
answer
275
views
jquery class-selector vs qualified class-selector
I am currently writing my bachelorthesis about webperformance and just came across some results I didn't expect.
As Paul Irish or jquery itself recommend it's always best to descend from an id.
http:/...
0
votes
1
answer
313
views
jQuery: Is using children() more efficient than using child selector
I often need to setup jQuery events on li tags that don't have a class or ID associated with them like in this example:
<div id="menu">
<ul id="nav">
<li>Nav Item ...
2
votes
1
answer
660
views
Jquery - Fastest way to get children elements [closed]
my work requires me to work with jquery a lot.
Since i am always trying to find a better way to do things, i would like to improve performance on javascript level of page.
so i was wondering what is ...
0
votes
1
answer
23
views
jQuery selector performance options
I working on this code currently
var cctypeid = $(this).attr("id");
var data = $.parseJSON($("#"+cctypeid+"-id").val());
$.each(data, function (index, item) {
});
Inside the .each() I need ...
0
votes
1
answer
120
views
Operations degraded by DOM complexity?
I stumbled across this jsperf.
It tests the relative performance of editing the html of an element accessed by id only or by id via a cached selector.
The element edited is 17 levels deep.
jsperf ...
0
votes
2
answers
47
views
Jquery using multiple selectors to show all at a time
I have jquery code to show 3 items at a time
$('.a').show();
$('.b').show();
$('.c').show();
I can also achieve the same with
$('.a, .b, .c').show();
What is main difference between both codes? ...
8
votes
5
answers
360
views
Best method to select an object from another unknown jQuery object
Lets say I have a jQuery object/collection stored in a variable named obj, which should contain a DOM element with an id named target.
I don't know in advance if target will be a child in obj, i.e.:
...
0
votes
5
answers
86
views
Is there a direct way (at the lower level) to do $('#id')?
I mostly call jQuery elements by the id of the DOM object using the $('#id') syntax. I think that this goes through the selector algorithm, and spends some time on that process.
I was wondering if ...