June 19, 2008
Idea tank: package JS libraries with browser releases
Here’s an idea: when your browser detects a specific naming pattern in the script tag, specifically the name of a commonly used Javascript library, it would load the local version of that file. If your browser doesn’t have that specific version, browser behavior would be as is. For example:
<script src="js/jquery-1.2.6.min.js" type="text/javascript" />
Your browser detects the string “jquery-1.2.6-min.js” inside a <script> tag and loads the local file instead of downloading the file. Which has two major advantages: speed, and zero caching problems.
This would be so much better than the Google AJAX Libraries API. I’m kind of talking outside of my comfort zone here, so tell me: am I being overly simplistic, or would this be totally awesome?
I think this definitely could be a good idea, although I’ve heard it presented before differently (using a non-standard extra parameter such as library=”jquery” in the script tag, rather than going off of the file name).
It seems like there could/should also be a way to get the latest stable version of a particular library, rather than having to update the script tags at each revision. This does of course lead to potential bugs in your code when a new version is released.
December 2nd, 2008 at 9:35 ∞