components / jquery

Shim repository for jQuery.

Home Page:http://jquery.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use of non-specific version is harmful

opened this issue · comments

According to jQuery's official position, referencing non-specific versions of javascript libraries is considered harmful and they reference this article on the matter.

Therefore we should probably add the version numbers to the source file names. The benefits seem to outweigh any disadvantages.

/cc @RobLoach

commented

The article explains that google cdn does not cache non-specific versions, not that what we do is bad

@Nami-Doc This ticket has nothing to do with CDNs. By having fixed file-names/paths then any static files then they are likely to be cached by browsers and not re-fetched. So when you update from one version to the next, you cannot be sure your visitors will get the new library. That is why the version should be specified - the files should be renamed to either something like

jquery-1.10.1.js
jquery-1.10.1.min.js

or

jquery/1.10.1/jquery.js
jquery/1.10.1/jquery.min.js

This is a very well known issue.

commented

If you're not concatenating files in production, I guess you have a bigger problem that this.
We could provide another min.js with it, but not on the not-minified files.

That's not entirely fair. It's perfectly conceivable one might only be using jQuery so there may be no need to combine assets in this case. I agree asset management is important, but it's no reason that we should not follow good practice.

commented

Yeah, but they ought to use the minified version. Forcing other people unnecessary maintenance burden is not ok.

What has minification got to do with it? minified or not it needs to be a fresh URL, that is the point to overcome caching.

There is no extra work for us. We're maintaining shim repositories there is no more work involved than copying the files from a tagged version of upstream as we do already but into a separate folder pertaining to version number.

Doesn't your package manager tell you what version you're using? Could even check the meta-tag information as well.

composer show
component ls
bower list

Having the version number in the name could be destructive as many people just download jQuery, and then assume jquery.js is there. Having to rename the file each time we release a new version would also be a lot more maintenance than is currently there.

I agree that targeting a non-specific version of a package is distructive, but that's up for users to do. If they want soft-dependencies, then they can go right ahead. Composer's solution around this is with composer.lock files, which locks the version number to a specific version once it's installed. Bower/Component might not have a solution around this, but it really comes down to the package manager and how the user wants to use it. Having the version number in the file name would just put a lot more maintenance on us.

What if we were to add a note in jQuery's README.md saying that they don't quite live up the Semantic Versioning's standards?