150 points · by Uncle_Sam · 15y ago · 97 comments
If anyone is not aware, one of the best CDNs out there for getting jQuery is the Taylor Swift "TaylorNation" cdn.
http://cdn.thetaylornation.com/taylornation/resources/displa...
I encourage everyone to use it.
How have I never heard about this hilarious script before?
'PI': 3.21. Every built in in Javascript can be overwritten.
2. If you see something like ObjectName.prototype.fnName, then what you're doing is defining a new fnName function on ObjectName. The thing about Javascript is that you can add new functions to objects, and since everything can be overwritten, you can also replace old functions with new ones. So when you do something like Array.prototype.sort = function(){...} then you're overwriting the builtin sort method on Arrays. Most of the script is just defining builtins to have bogus results.
3. Javascript has a built in Math object, like a few other languages. The language also allows you to create objects on the fly with bracket notation: the layout is key: value. So the Math definition defines Math.PI to be 3.2.
4. There are a few other jokes in there too (like defining alert, which makes a message box, to be eval, which evaluates the string).
Could be improved a bit, though. Many of its entries lack subtlety. If you really want to be evil, make uppercase do something like uppercase all but one letter, or "uppercase" the digit 1 into exclamation marks, 2 into at signs, etc., convincing the poor developer that the JS upper case function is broken and affect digits. ("Must be unicode or something.")
Many of its entries lack subtlety.
An Underhanded Javascript contest would be amusing.Then again, maybe the point is to muddy your own waters? I'm reminded of an aphorism dealing with activities that should not be undertaken near one's place of slumber.
This would probably be the best way to transition. If they add an alert to their library and leave it up a week, most people should notice and fix it.
<script>
var oldAlertFunction = window.alert;
window.alert = function(){};
</script>
<script src="crockford.com/json.library.js"></script>
Arms race, but just sayin'<script> var oldAlertFunction = window.alert; window.alert = function(){}; </script>
<script src="crockford.com/json.library.js"></script>
<script>
window.alert=oldAlertFunction;
</script> if (location.host.search(/crockford.com$/i) != -1) {
alert("Stop hotlinking me!")
}
I don't think you can fool that, but I'd love to hear about how I'm wrong.I guess I shouldn't be but I'm still surprised people would even do this given that Google s offering the service for free. Hotlinking has always been antisocial.
I'm actually more surprised that the site didn't either use Google's API to host the download, or provide a hotlink button right there.
This also applies when .js is dynamically included as a type of API call to embed widgets and whatnot - but in those cases there's a necessary reason - it's the only practical way - but for a simple .js, you should be managing your own .js library and publishing on your own (including all the speedup tricks you know you should be doing)
This is why I can't understand people's recommendation to use Google's or Microsoft's CDN. Even if you assume they're not going to be malicious, you have to trust that they're secure. Not to mention that the CDN owner can derive accurate traffic stats from the number of requests for the JavaScript.
In a perfect world, the CDN would only handle one HTTP request per user per expires period (+1 year on Google and Microsoft's jQuery CDN). In reality, the file will be pushed out of or cleared from caches for various reasons, but they still persist long enough to make tracking end-usage of the CDN meaningless.
That said, I'm open to the idea that I'm being extremely foolish about this ;)
CPanel allows you to do this directly (although you might want to back up your .htaccess file first).
(Up to date CDN links for a bunch of javascript libraries, including jquery)
- Listing the sites that hotlink it would be a nice idea.
- Changing the script on the hotlinked files to pop-up a warning that the site is doing something improper and urging people to contact the owner.
- When that doesn't work, break the sites.
To me, that seems like the polite thing to do.
Well indeed, but even if you ignore the time taken to do WHOIS lookups and presume that they'll go to the right person (e.g. blogs hosted on Wordpress.com) you're still ignoring the serious amount of computing power that it takes to send a significant number of emails.
I'm assuming we're talking about thousands of emails here, not millions.
When was the last time you tried sending thousands of emails? It's a surprisingly non-trivial task to send more than a few hundred emails - and that's ignoring setting off spam filters and getting IP addresses blacklisted.
Speaking honestly, I like your idea, but it's my opinion that if it were that simple then the jQuery guys would do it. Since it isn't that simple, they're not.
Hotlinking like this has been a well known web evil for well over a decade. That people still do it and just hope for the best is indicative of extraordinary laziness and selfishness.
They could just break all those sites without giving them personalised warnings, yes. And they would also be completely entitled to yes. But for the small amount of effort needed, why not try to minimise the damage.
I'm attributing laziness, which is quite removed from malice. People using jquery should be evolved enough to know what CDNs are, and the dangers of hotlinking (which is as simple as "jQuery decided to reorganize their site, and now a thousand sites are broken").
Except where the site expressly permits it.
http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js (always the latest version)