Live data from Hacker News

jQuery CDN having SSL issues

code.jquery.com

11–20 of 59 posts

Re: jQuery CDN having SSL issues

#11
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 with local fallback (or visa versa) has been common now for decades but yet no official support at all. Honestly if the integrity attribute is specified the browser should just be able to fall back to a cached copy it has (e.g. jquery.1.2.3.min.js has a crypto hash of ABC123, and I have that file already).

[0] https://stackoverflow.com/questions/7383163/how-to-fallback-...

Re: jQuery CDN having SSL issues

#15
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 compared to self-hosting?

Re: jQuery CDN having SSL issues

#16

This is why you self-host all project dependencies.

But that costs you cache hits, increases the real world size of your site, and slows loading. I'm sure mobile users with metered internet would prefer you didn't download that 100 KB JavaScript library for the nth time.

Re: jQuery CDN having SSL issues

#17
post #9

Great opportunity to strip out unnecessary uses of jQuery, and move to vanilla javascript. http://youmightnotneedjquery.com/

I haven't used jquery in about 2 years, pure javascript and maybe some lodash functions imported into my es6. Give it a try, you might not need it!

Re: jQuery CDN having SSL issues

#19

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…

Yeah, I think the latest and greatest in web standards for solving this problem would probably be using a Service Worker to transparently handle the failure and serve up a fallback... but like you said, that's a JavaScript-based solution.

Re: jQuery CDN having SSL issues

#20

  Original, jQuery CDN:
  https://code.jquery.com/jquery-X.Y.Z.min.js

  Google:
  https://ajax.googleapis.com/ajax/libs/jquery/X.Y.Z/jquery.min.js

  Microsoft:
  https://ajax.microsoft.com/ajax/jquery/jquery-X.Y.Z.min.js

  Microsoft ASP.NET:
  https://ajax.aspnetcdn.com/ajax/jquery/jquery-X.Y.Z.min.js

  jsDelivr:
  https://cdn.jsdelivr.net/npm/jquery@X.Y.Z/dist/jquery.min.js

  cdnjs:
  https://cdnjs.cloudflare.com/ajax/libs/jquery/X.Y.Z/jquery.min.js

  Yandex.ru:
  https://yastatic.net/jquery/X.Y.Z/jquery.min.js
Post reply on HN