News for hackers. Stuff that matters.
Re:AMP for email is a terrible idea by ehnto on Tuesday February 13, 2018 @09:01PM (#16372827)
Part of why I don't advocate for CDNs when you don't need them is because I want to build robust sites that work for years untouched. For timespans over a year, anything not on your server is brittle. Oops, CDN changed its URL/didn't update their ssl ciphers/went bust and shut down completely and now {js-framework}/{css-library} is missing and my site is broken. What an unforeseeable circumstance!
Re:AMP for email is a terrible idea by jjeaff on Tuesday February 13, 2018 @09:21PM (#16372902)
That's why I like to map one of my own subdomains to the cdn service.

So everything is at cdn.example.com and if I change providers, it's just a dns record change and everything is ready, even if I want to just host my own content.

Re:AMP for email is a terrible idea by y03a on Tuesday February 13, 2018 @10:02PM (#16373078)
Doesn't that kill the possibility that a visitor will already have common content cached when visiting your site for the first time? I know that's not the only reason to use a CDN, but it's a pretty big one.
Re:AMP for email is a terrible idea by vanadium on Tuesday February 13, 2018 @10:14PM (#16373126)
In my experience, the variety of specific versions of libraries sites are locked to dilutes that performance benefit. Just look at a cross-sampling of sites calling jQuery or <insert your favorite library or framework here>.

In theory, the maximum benefit of a CDN only comes if everyone is on 1) the same version or, similar but different, 2) an evergreen version. And the latter is a big red neon sign screaming "DANGER".

Re:AMP for email is a terrible idea by tripzilch on Thursday February 15, 2018 @01:05PM (#16386111)
And the parts that everyone is on, became standardized in the browser: document.querySelector, CSS animations, async stuff, etc.
Re:AMP for email is a terrible idea by toast0 on Tuesday February 13, 2018 @10:13PM (#16373122)
Honestly with all the versions of js libraries and all the CDN hosts, the limitations of cache size and the insane bloat of webpages, I think you're going to have to be pretty lucky to get any beneficial cache hits from unrelated third party sites.
Re:AMP for email is a terrible idea by jjeaff on Tuesday February 13, 2018 @11:13PM (#16373412)
IF you have some stuff you think some visitors will have cached, well then you can use the standard google or jquery CDN or whatever (they're free anyway). For everything else you would run from your own CDN url.
Re:AMP for email is a terrible idea by LoSboccacc on Wednesday February 14, 2018 @12:28AM (#16373701)
I thought that too but even for the most common stuff like font awesome cdn cannot be trusted - just too many silent outages that were only discovered from user complaining because they impacted different geographical areas differently..
Re:AMP for email is a terrible idea by tripzilch on Thursday February 15, 2018 @01:02PM (#16386083)
IIRC the argument was that JS bloat is okay "because we can cache common content through CDNs" ... or that's how it felt at the time :)

It sort of/kind of started with jQuery, and in those days including jQuery was considered somewhat bloaty. I think it was about 18kB minified back then? Today their site says it's 30kB.

Either way that's miniscule compared to having a few pictures on your webpage. Having much more JS than that, honestly seems like true bloat to me, which I don't think CDNs should facilitate anyway (so much untrusted unknown unchecked code doing very, very filthy things).

My point is, it wasn't a very good argument back then either, but it became normal because people did it for other reasons, too.

The main reason people did it, was that it was just so much easier. Just copypaste those 1.5 lines of code in your <HEAD> section to include the latest version of jQuery from Google's CDN, instead of downloading it and putting it somewhere in your source tree and now you've got to keep track that different parts of your codebase written months apart don't accidentally use slightly different versions (because it's ugly, not because it mattered a lot otherwise), etc.

Such convenience!

And if someone asked if it was really a good idea to blindly load 3rd party code and run it in the context of your own domain? Even I told people this sometimes: Well if you can't trust Google serving you secure code, then the web is basically fucked anyway, and we got much bigger problems. Which seemed like a reasonable threat model / security trade off at the time.

And now we're here.

About a week ago Google got caught hosting hostile ads that included cryptocoin miners inefficiently wasting users' electricity for a few bucks (profit insignificant compared to the cost of energy wasted). And apparently Google's offering to blindly host 3rd party JS to all users on the entire Internet everywhere (except the adblockerati), via their fucking ad network, has been expected behaviour for over a year at least and nobody gave a peep when that malfeature appeared.

I still don't know the exact date when or if there even was an announcement when they allowed advertisers "sure do whatever you like to their browsers, run some code, compute stuff, track them in all the ways we haven't dared to deploy publicly, or yet thought of, have at it, you need this, you do you".

So yeah, the web is fucked, we got bigger problems and hell no you can't trust Google any more.

Re:AMP for email is a terrible idea by bigbugbag on Saturday February 17, 2018 @07:06AM (#16400341)
> Either way that's miniscule compared to having a few pictures on your webpage.

A visitor can decide to not display images to improve performance and this will not break the website, blocking the (often not useful) js on the other hand...

> And if someone asked if it was really a good idea to blindly load 3rd party code and run it in the context of your own domain? Even I told people this sometimes: Well if you can't trust Google serving you secure code,

You overlooked the privacy and personal data issue here. It's a bad idea to rely on anything google because it means that you give away the privacy of your visitor to one of the worst offender no less.

> About a week ago Google got caught hosting hostile ads ...

Google has been delivering malware, spyware and that kind of things for years. It was even considered a major vector of infection (usually someone looked for flash on google and clicked on the first results which happened to be a google ad for an infected flash installer)

Re:AMP for email is a terrible idea by brandon272 on Tuesday February 13, 2018 @10:42PM (#16373269)
Wouldn't the paths change between providers?
Re:AMP for email is a terrible idea by jjeaff on Tuesday February 13, 2018 @11:08PM (#16373390)
Many providers simply map to your live site structure. So I keep everything on my own site and do the initial upload there. The CDN looks to my site to get the original copy when they receive a request for a file they don't have cached.
Re:AMP for email is a terrible idea by pasta on Wednesday February 14, 2018 @03:52AM (#16374485)
Dont't forget build tools.

Good luck updating a site that used the latest and greatest build tools that are now depricated.

Fun thing: a lot of times I download the Javascript from a CDN because then I don't need build tools because it was already built for me on the CDN...

People focus too much on ship fast.

They get in trouble when the product becomes a success.

Re:AMP for email is a terrible idea by gowld on Wednesday February 14, 2018 @01:54PM (#16378222)
Right, better to have your site fail today, then to risk it failing in the future. You couldn't make an archive of your site for emergency access.
Re:AMP for email is a terrible idea by ehnto on Wednesday February 14, 2018 @06:04PM (#16380384)
Why would it fail today? If I can't serve an asset then my whole server is down.

If you are an e-commerce site serving hundreds of images worldwide then CDNs make a tonne of sense.

If you just have a simple site or SaaS getting decent traffic, why add a failure point by including your choosen JS with a CDN. No one batts an eyelid when you add ten images to the homepage but somehow a single, much smaller JS file is too much extra load. It doesn't stand up to reason.

Re:AMP for email is a terrible idea by ehnto on Wednesday February 14, 2018 @08:43PM (#16381294)
Noting I couldn't quite figure out the tone of your comment to know if you were agreeing or disagreeing.