CodeSOD: Load, Load, Load your Deps
It's not uncommon for web applications to fetch key dependencies from remote, public CDNs. Why host Angular or jQuery yourself, when Google will do it for you? That, at least, was part of the logic underpinning this old code Dan found.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script><script>window.jQuery || document.write('<script src="js/vendor/jquery-1.9.1.min.js"><\/script>')</script><script src="js/jquery.js"></script>
First, we fetch the jQuery 1.9.1 library from Google. Then, we add another script, and check: if window.jQuery is defined, great- but if not, we load a local version of the 1.9.1 jQuery library. Then... we unconditionally load an unversion-tagged version of the jQuery library.
"I like a dev who double-checks everything," Dan writes. "Even triple-checks are fine."
There's just one note on those triple-checks, Dan notes.
[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!But here's the first line of the "js/jquery.js" file:
/*! jQuery v@1.8.0 jquery.com | jquery.org/license */