3 ms·
By "more efficient" it seems like you mean "less typing" because that is significantly less efficient in terms of downloaded code size and performance (the jQue
by my69thaccount 4y ago
By "more efficient" it seems like you mean "less typing" because that is significantly less efficient in terms of downloaded code size and performance (the jQuery code calls the vanilla code.)
PS. $ is an alias for document.getElementById so you can just do $('my_id').style.display = 'none'.
- pastor_bob 4y agomost people probably have jquery cached in their browser if you're pulling it from the google cdn
- my69thaccount 4y agoThat hasn't been the case for years because of per-origin caching. CDNs get their performance from edge routing, not caching.
- jameshart 4y agoThanks to cache partitioning, this is no longer true. See, it turns out that by carefully leveraging cached retrieval of third party resources, scripts on two different domains can figure out if they are running in the same web browser, effectively pulling off browser fingerprinting. To stop this, modern browsers don’t share third party resource caches cross domain. So using a well known CDN no longer confers any benefit - even if a user has pulled down jquery for another site’s benefit, when they come to your site and you request the same resource, the browser will go out and re-retrieve it, to prevent you or the third party domain from being able to infer anything about the user based on the speed of the response or whether or not the request got made.
- pastor_bob 4y agoahh wasn't aware, and good to know
- jameshart 4y agoIndeed. We cannot have nice things.
- sensanaty 4y agoLocalCDN is great for this! Avoids both the privacy concerns, plus makes things a bit speedier as everything is readily available locally already
- dbbk 4y agoAs others have mentioned this isn't the case, also the browser still has to parse that JavaScript, which for a lower end mobile phone is often significant.