Hacker News new | past | comments | ask | show | jobs | submit login

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'.




most people probably have jquery cached in their browser if you're pulling it from the google cdn


Thanks 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.


LocalCDN is great for this! Avoids both the privacy concerns, plus makes things a bit speedier as everything is readily available locally already


ahh wasn't aware, and good to know


Indeed. We cannot have nice things.


As 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.


That hasn't been the case for years because of per-origin caching. CDNs get their performance from edge routing, not caching.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: