Jquery-validation: Missing minified JavaScript code from npm package

Created on 19 Apr 2016  路  8Comments  路  Source: jquery-validation/jquery-validation

Hey,

I'm using the jQuery Validation plugin via npm. After running npm install jquery-validation the minified JavaScript code is not downloaded to node_modules/jquery-validation/dist. Would you consider adding it?

Best,
C膬t膬lin

Most helpful comment

Of course we can do that but it's not what I expected. I asume a package contents are identical regardless the package is downloaded as zip, hotlinked from a CDN or installed via a package manager.

In this case I use npm to manage project dependencies, including jQuery Validation. The build process takes care of the project sources indeed, but only ours. Vendored assets are simply copied from the node_modules directory, then linked to a CDN (if any available) with local fallback. See an example:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/jquery.validate.min.js"></script>
<script>window.jQuery.fn.validate || document.write('<script src="{{ site.baseurl }}/assets/vendor/jquery-validation/jquery.validate.min.js"><\/script>')</script>

I try to avoid manually downloading and adding any packages to a repository especially if they are provided via a package manager.

A few more packages used: dotdotdot, jquery, jquery.scrollto, slick-carousel. All of them provide a full distribution via npm - allowing us to access wanted resources with ease. That's how a dependency should work, you plug it in and it works, right?

I agree this is more of a request than an issue but would help us (and others too) making use of npm packages more consistent. What do you think? Does it make any sense to you?

All 8 comments

Shouldnt your build process take care of minifying and combining the overall projects javascript sources? I see no point in shiping a pre-minified version in npm

Of course we can do that but it's not what I expected. I asume a package contents are identical regardless the package is downloaded as zip, hotlinked from a CDN or installed via a package manager.

In this case I use npm to manage project dependencies, including jQuery Validation. The build process takes care of the project sources indeed, but only ours. Vendored assets are simply copied from the node_modules directory, then linked to a CDN (if any available) with local fallback. See an example:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/jquery.validate.min.js"></script>
<script>window.jQuery.fn.validate || document.write('<script src="{{ site.baseurl }}/assets/vendor/jquery-validation/jquery.validate.min.js"><\/script>')</script>

I try to avoid manually downloading and adding any packages to a repository especially if they are provided via a package manager.

A few more packages used: dotdotdot, jquery, jquery.scrollto, slick-carousel. All of them provide a full distribution via npm - allowing us to access wanted resources with ease. That's how a dependency should work, you plug it in and it works, right?

I agree this is more of a request than an issue but would help us (and others too) making use of npm packages more consistent. What do you think? Does it make any sense to you?

Here are five important reasons why shipping the minified version is a good thing:

  1. To support Subresource Integrity (SRI) - This is used to ensure that the copy of a file on a CDN has not been tampered with. The minified file on the CDN is compared to a local copy but for that to happen both minified copies need to be the same! If you don't provide a minified copy, then people will use their own minified file which may be different. The only way around this is to manually download the copy on the CDN instead, thus removing the need for the NPM package entirely!
  2. Using Uglify on jQuery outputs a larger script than the one they officially provide. They must use specific settings to get the smallest file possible.
  3. The minified script is the final product, not the unmodified script. All large projects provide a minified script.
  4. People don't want to have to fire up a build pipeline just to minify this file. An unminified copy should be provided just for the pure convenience of it!
  5. The number of upvotes @cdog has got.

thx for the detailed writeup. I merged your PR.

Much obliged sir!

@staabm, @RehanSaeed great, thanks for fixing this!

hopefully I can have a look at some of the open issues/PRs this friday and release a 1.15.2.

@staabm sounds good, thanks for your efforts!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MartinRobins picture MartinRobins  路  9Comments

gimler picture gimler  路  5Comments

mapeveri picture mapeveri  路  4Comments

francoism90 picture francoism90  路  3Comments

nathanl picture nathanl  路  6Comments