Giter Club home page Giter Club logo

Comments (10)

WebReflection avatar WebReflection commented on June 2, 2024

I don't think so, you can use document.queryAll('.class-name') instead. I am not planning to add another live collection on the plate, these are slow, greedy, dated, etc.

from ie8.

alphanull avatar alphanull commented on June 2, 2024

Well, I think I have to disagree here:

  1. You already added other DOM related functions like previousElementSibling, so I think it would fit to also add this one, its simply missing in IE8 like the other ones.
  2. It would be relatively easy to implement
  3. using getElementsByClassName is way faster than using document.queryAll in browsers that natively support it (see https://jsperf.com/getelementsbyclassname-vs-queryselectorall/25)
  4. therefore if you want to use this (and still support IE8), you either have inferior performance with having to use queryAll, or end up doing some kind of browser sniffing and adding a branch - and have much more convoluted code - or you have to use another shim just for this case.

Wouldn't it be much more convenient to have a single shim that handles it all? So please consider adding this.

from ie8.

WebReflection avatar WebReflection commented on June 2, 2024

Do you understand what is a live collection? I think you are not
considering what it takes to implement it in IE8, it will kill
performances, not improve them. The direction is in any case to use
.query() and .queryAll() which are polifilled for IE8 too in the DOM4 poly.

I won't waste time in here to support a live collection for a death
browser. Apologies for any inconvenience. PR with standard compliant tests
welcome.
On Nov 18, 2015 4:43 PM, "alphanull" [email protected] wrote:

Well, I think I have to disagree here:

  1. You already added other DOM related functions like
    previousElementSibling, so I think it would fit to also add this one, its
    simply missing in IE8 like the other ones.
  2. It would be relatively easy to implement
  3. using getElementsByClassName is way faster than using
    document.queryAll in browsers that natively support it (see
    https://jsperf.com/getelementsbyclassname-vs-queryselectorall/25)
  4. therefore if you want to use this (and still support IE8), you either
    have inferior performance with having to use queryAll, or end up doing some
    kind of browser sniffing and adding a branch - and have much more
    convoluted code - or you have to use another shim just for this case.

Wouldn't it be much more convenient to have a single shim that handles it
all? So please consider adding this.


Reply to this email directly or view it on GitHub
#22 (comment).

from ie8.

alphanull avatar alphanull commented on June 2, 2024

Yes I am aware what a live collection is. But I (and I guess many others as well) do simply not need a live collection behavior as I only want to get a reference to element(s) with a certain class and immediatly do something with them. So yes, there would be a difference to the native function but at least I could live with that restriction.

But I understand that you do not want to implement something that is not 100% compliant, and I see that making it act as a live collection would add quite some work and also performance implications. OK, DOM4 shim also adds query() but I guess I still have to use just another shim due to performance reasons.

And yes, IE8 is surely dead, but unfortunately not as dead as I want it to be. Was shocked with a recent project to still see all those IE8s when analysing some log files :(

from ie8.

WebReflection avatar WebReflection commented on June 2, 2024

The thing is, the effort needed to implement, test, and maintain a possibly
broken shim out weight the benefit. Is getElementsByClassName really
the bottleneck, in terms of performance, for your project?
On Nov 18, 2015 5:28 PM, "alphanull" [email protected] wrote:

Yes I am aware what a live collection is. But I (and I guess many others
as well) do simply not need a live collection behavior as I only want to
get a reference to element(s) with a certain class and immediatly do
something with them. So yes, there would be a difference to the native
function but at least I could live with that restriction.

But I understand that you do not want to implement something that is not
100% compliant, and I see that making it act as a live collection would add
quite some work and also performance implications. OK, DOM4 shim also adds
query() but I guess I still have to use just another shim due to
performance reasons.

And yes, IE8 is surely dead, but unfortunately not as dead as I want it to
be. Was shocked with a recent project to still see all those IE8s when
analysing some log files :(


Reply to this email directly or view it on GitHub
#22 (comment).

from ie8.

alphanull avatar alphanull commented on June 2, 2024

Yes, of course it can hurt performance, and it imho does not even have to be the bottleneck. I mean, why should I use querySelector in the first place when I know that using getElementsByClassName is from about 100x up to 3000x(!) faster in a browser that natively supports it - and of course thats the majority of them. It just hurts a bit to need additional measures to cope with IE8, if a relatively simple shim would suffice, without needing it to be 100% compliant.

from ie8.

WebReflection avatar WebReflection commented on June 2, 2024

I wrote it badly, let me rephrase : is the absence of
getElementsByClassName really a bottleneck for you? I'd love to see the
rest of the code or a profiled snapshot. Microbenchmarks are not a valid
source of data. The whole picture is.
On Nov 18, 2015 5:54 PM, "alphanull" [email protected] wrote:

Yes, of course it can hurt performance, and it imho does not even have to
be the bottleneck. I mean, why should I use querySelector in the first
place when I know that using getElementsByClassName is from about 100x up
to 3000x(!) faster in a browser that natively supports it - and of course
thats the majority of them. It just hurts a bit to need additional measures
to cope with IE8, if a relatively simple shim would suffice, without
needing it to be 100% compliant.


Reply to this email directly or view it on GitHub
#22 (comment).

from ie8.

alphanull avatar alphanull commented on June 2, 2024

I think I understand what you mean ;) And I also know the issues with micro- or premature optimization. No, its not really a bottleneck, but on the other hand, I have no huuge bottleneck at all - I think at least. Its all those little things which add up, and I tend to avoid ways to slow down my code when I know that theres a more performant way to do it. Call it micro-optimization - but in this case I think it does not hurt me in any way to go a faster route from the beginning.

from ie8.

WebReflection avatar WebReflection commented on June 2, 2024

Considering I won't add the method, what stops you to use a one-line non
standard HTMLElement.prototype.getElementsByClassName that returns
this.querySelectorAll ('.'+className) ?
On Nov 18, 2015 6:23 PM, "alphanull" [email protected] wrote:

I think I understand what you mean ;) And I also know the issues with
micro- or premature optimization. No, its not really a bottleneck, but
on the other hand, I have no huuge bottleneck at all - I think at
least. Its all those little things which add up, and I tend to avoid ways
to slow down my code when I know that theres a more performant way to do
it. Call it micro-optimization - but in this case I think it does not hurt
me in any way to go a faster route from the beginning.


Reply to this email directly or view it on GitHub
#22 (comment).

from ie8.

alphanull avatar alphanull commented on June 2, 2024

Yeah, I guess that's exactly what I will do.

from ie8.

Related Issues (20)

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.