I'm trying to be able to add a query to my js file that will change the versions.
For example:
<script type="text/javascript" src="myjavascript.js?v=1.0.0"></script>
I know this is possible because I seen other sites do this.
Thanks for help.
I'm trying to be able to add a query to my js file that will change the versions.
For example:
<script type="text/javascript" src="myjavascript.js?v=1.0.0"></script>
I know this is possible because I seen other sites do this.
Thanks for help.
Versioning of JS files in this fashion is nothing more than a technique to force a refresh of a particular cached resource on a user's machine. When you append a unique querystring to a URL, it tells the browser that it should not used a cached version of a particular URL and it forces the browser to redownload that file.
Making use of this functionality is as simple as appending a unique value onto the querystring of the JS file's URL.
What you're most likely seeing is a server-side language such as ASP, PHP, etc. "swoop in" and handle the change, then render the contents out as if nothing has happened. Basically, if you can relate to PHP:
<?php
$v = $_GET['v']; // yes I know--shame on me for no validation
header('Content-Type: text/javascript');
include('js/myjavascript-'.$v.'.js');
The other purpose is, as Nathan mentioned, for avoiding caching issues. But, if you see the script's contents changing based on this GET variable it's most likely a server-side language doing so nondescript.