Live data from Hacker News

jQuery CDN having SSL issues

code.jquery.com

21–30 of 59 posts

Re: jQuery CDN having SSL issues

#21
Years ago, I used to link the library from Google [1] or CloudFlare [2].

Nowadays, with all the Node.js stuff that goes around modern front-end, I don't see the point of embedding a JavaScript library from a CDN, unless that library is dependent on a remote service, e.g. Google Analytics, Google Maps, etc… That being said, if you are still maintaining a legacy website that depends on jQuery, you should consider to embed the library like this instead:

window.jQuery || document.write('')

[1] https://developers.google.com/speed/libraries/

[2] https://cdnjs.com/libraries/jquery

Re: jQuery CDN having SSL issues

#22

I always self-host my JS/CSS libraries: the connection is already open (thanks to keep-alive) so what's the problem of serving a couple of more KiBs of compressed data instead of making an additional DNS request and a new connection to a CDN? I understand that the CDN version of the library may have already been cached by the browser while visiting other websites, but does it really save that much time/traffic compar…

I'm not taking a side, just trying to add some numbers. Let's ignore the privacy/uptime concerns for the sake of this comment.

If every site you visit has 350kb of stuff that would benefit from a CDN JS but also some CSS and fonts (google fonts, bootstrap, etc.) If you visit 50 pages a day in a 30 day month, that's a little over 500mb of data.

.35mb x 50sites x 30days = 525mb

That would be a ton of easily avoidable data in regards to mobile plans depending on where you are. This number isn't 100% accurate though, many "normal" (read - not techy hackernews readers) might only visit say a dozen sites a day or less (let's ignore apps like facebook/snapchat/etc). Even that might be a stretch.

Then again students and other "savy" users might be going across hundreds of new sites a day.

For you the host? Unless you're a massive beast, most of us "hobbiests" fit within the free bandwidth of 5$ vps services anyway.

Re: jQuery CDN having SSL issues

#23

Years ago, I used to link the library from Google [1] or CloudFlare [2]. Nowadays, with all the Node.js stuff that goes around modern front-end, I don't see the point of embedding a JavaScript library from a CDN, unless that library is dependent on a remote service, e.g. Google Analytics, Google Maps, etc… That being said, if you are still maintaining a legacy website that depends on jQuery, you should consider to em…

> Nowadays, with all the Node.js stuff that goes around modern front-end, I don't see the point of embedding a JavaScript library from a CDN, unless that library is dependent on a remote service, e.g. Google Analytics, Google Maps, etc… That being said, if you are still maintaining a legacy website that depends on jQuery, you should consider to embed the library like this instead:

What does Node.js have to do with deciding whether to get your static assets from a public CDN or not? I hope your not serving your static assets with Node.js.

Re: jQuery CDN having SSL issues

#24

I always self-host my JS/CSS libraries: the connection is already open (thanks to keep-alive) so what's the problem of serving a couple of more KiBs of compressed data instead of making an additional DNS request and a new connection to a CDN? I understand that the CDN version of the library may have already been cached by the browser while visiting other websites, but does it really save that much time/traffic compar…

I'm not taking a side, just trying to add some numbers. Let's ignore the privacy/uptime concerns for the sake of this comment. If every site you visit has 350kb of stuff that would benefit from a CDN JS but also some CSS and fonts (google fonts, bootstrap, etc.) If you visit 50 pages a day in a 30 day month, that's a little over 500mb of data. .35mb x 50sites x 30days = 525mb That would be a ton of easily avoidable d…

Unfortunately everyone still ends up using many different versions or adding other unnecessary querystring parameters so that each site still effectively ends up with their own file to download.

Re: jQuery CDN having SSL issues

#25

Years ago, I used to link the library from Google [1] or CloudFlare [2]. Nowadays, with all the Node.js stuff that goes around modern front-end, I don't see the point of embedding a JavaScript library from a CDN, unless that library is dependent on a remote service, e.g. Google Analytics, Google Maps, etc… That being said, if you are still maintaining a legacy website that depends on jQuery, you should consider to em…

> Nowadays, with all the Node.js stuff that goes around modern front-end, I don't see the point of embedding a JavaScript library from a CDN, unless that library is dependent on a remote service, e.g. Google Analytics, Google Maps, etc… That being said, if you are still maintaining a legacy website that depends on jQuery, you should consider to embed the library like this instead: What does Node.js have to do with de…

> What does Node.js have to do with…

There are tools like Grunt and WebPack (which depend on Node.js) that can bundle all your dependencies.

I cannot provide details about how they work because I don't do front-end development, but I can tell you about years ago when I had to copy & paste both code and links to jQuery and other libraries like BackBone or Ember.js (relevant at the time) into my projects. Nowadays, web developers seem to prefer the use of tools that came from the Node.js ecosystem to handle these dependencies in a more "engineer-ish" way using NPM packages.

Re: jQuery CDN having SSL issues

#26

I always self-host my JS/CSS libraries: the connection is already open (thanks to keep-alive) so what's the problem of serving a couple of more KiBs of compressed data instead of making an additional DNS request and a new connection to a CDN? I understand that the CDN version of the library may have already been cached by the browser while visiting other websites, but does it really save that much time/traffic compar…

Depending on where your hosting your app, you may or may not be paying for bandwidth. If your paying for bandwidth you might as well save some bucks and use one of the public CDNs.

Re: jQuery CDN having SSL issues

#27

Years ago, I used to link the library from Google [1] or CloudFlare [2]. Nowadays, with all the Node.js stuff that goes around modern front-end, I don't see the point of embedding a JavaScript library from a CDN, unless that library is dependent on a remote service, e.g. Google Analytics, Google Maps, etc… That being said, if you are still maintaining a legacy website that depends on jQuery, you should consider to em…

> Nowadays, with all the Node.js stuff that goes around modern front-end, I don't see the point of embedding a JavaScript library from a CDN, unless that library is dependent on a remote service, e.g. Google Analytics, Google Maps, etc… That being said, if you are still maintaining a legacy website that depends on jQuery, you should consider to embed the library like this instead: What does Node.js have to do with de…

I assume he's talking about NPM. Now that everybody's hot new SPA has a few hundred thousand NPM dependencies, you roll it all up using Webpack and can just as easily `npm install jquery` as ``.

Re: jQuery CDN having SSL issues

#28

Earlier quoted context omitted.

> Nowadays, with all the Node.js stuff that goes around modern front-end, I don't see the point of embedding a JavaScript library from a CDN, unless that library is dependent on a remote service, e.g. Google Analytics, Google Maps, etc… That being said, if you are still maintaining a legacy website that depends on jQuery, you should consider to embed the library like this instead: What does Node.js have to do with de…

> What does Node.js have to do with… There are tools like Grunt and WebPack (which depend on Node.js) that can bundle all your dependencies. I cannot provide details about how they work because I don't do front-end development, but I can tell you about years ago when I had to copy & paste both code and links to jQuery and other libraries like BackBone or Ember.js (relevant at the time) into my projects. Nowadays, web…

Yea you can still not bundle the actual library and grab it from a CDN, using webpack externals[1]. Using webpack doesn't really change anything.

[1]: https://webpack.js.org/configuration/externals/

Re: jQuery CDN having SSL issues

#30

It is too bad that the HTML standard has no built in way to fallback. They've added a cryptographic hash/integrity and the async/defer attributes to the script tag, but something as essential as a fallback if a script or stylesheet fails to load (which the browser is best placed to know), has no built in functionality. Instead you're left doing JavaScript tricks which for missing CSS gets a little ugly[0]. But CDN wi…

I mean, the fallback mechanism is progressive enhancement. It’s a reliability mechanism more than anything - if JS (or part of the JS) fails to load the site should fall back to a version that potentially reduces the interactivity but allows essential functions to continue.
Post reply on HN