npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

gulp-version-append

v0.2.0

Published

Cache-busting plugin for gulp.

Downloads

2,520

Readme

gulp-version-append

npm version Dependency Status

Gulp plugin to append version from package.json to static file url to avoid caching.

Pre-requirements

Have package.json file in your project root folder with version field.

Usage

In gulp task:

var versionAppend = require('gulp-version-append');

...
.pipe(versionAppend(extensionsArray[, options]))
...

extensionsArray - is an array of extensions that require version to be appended, e.g. ['html', 'js', 'css'] options - optional config object for custom params. options.versionFile - path to json file that contains version in case you're need to use different file instead of package.json (path should be relative to application root folder) options.appendType - override appending version with timestamp or short "guid" based on date (actually it's a date that counted from the beginning of current year in HEX). Possible values 'version','timestamp','guid', defaults to 'version'

In html code:

<script src="/js/scriptname.js?v=@version@"></script>

package.json:

{
  "name": "my-app",
  "version": "0.0.1"
}

result:

<script src="/js/scriptname.js?v=0.0.1"></script>

Example

var gulp = require('gulp'),
	$ = require('gulp-load-plugins')(),
	path = require('path');

gulp.task('html', function(){
    return gulp.src(path.join(__dirname, '*.html'))
		  .pipe($.versionAppend(['html', 'js', 'css']))
		  .pipe($.minifyHtml());
});
/// version.json:
{
	"version": "0.0.1"
}

/// gulpfile.js: 
var gulp = require('gulp'),
	$ = require('gulp-load-plugins')(),
	path = require('path');

gulp.task('html', function(){
    return gulp.src(path.join(__dirname, '*.html'))
		  .pipe($.versionAppend(['html', 'js', 'css'], {appendType: 'guid', versionFile: 'version.json'}))
		  .pipe($.minifyHtml());
});

Thanks

Many thanks to @bustardcelly and his gulp-rev-append (https://github.com/bustardcelly/gulp-rev-append/) plugin that was taken as an example for this plugin.

Another plugin? Why?

  • gulp-rev-append plugin is very good and in some cases even better, because it relies on file hash, so if file didn't changed between versions, the hash will remain the same so file can stay in cache. But in my case all files are concatenated to sevral files, so changing one file will cause change in big file. So in 95% cases file will change on version update. That's why I've wrote this plugin, which is slightly faster than gulp-rev-append because it not read files and not calculates their hash.
  • gulp-css-urlversion and it's analogues are limited to one static file type, but I need one unified plugin that could append version everywhere: in html, js, css, etc.
  • gulp-ver - very good plugin, but it rename files instead of appending query param. This is good practice in some cases, but not mine. I've tried to make my plugin simple as a pie, with minimum code modifications, renames, etc.
  • also I use angular and have a lot of stuff that needs version appending in js source code, but many plugins are limited and replace only usual url, that start with e.g. 'src=/js/myjs.js?rev='. My plugin relies only on file extensions and special "template": .<file_extension>?v=@version@.