This is often used to facilitate caching of the JS file. You set the Expires header for the future future, which means the browser can cache it for a very long time. If you change something in the file, you will also update the number in the query line, which will force the browser to restore the file. This works because caching is for unique file names, and the request is executed as part of the file name (as far as the browser is concerned).
A similar approach to this is to use rewriting rules on the web server to have some part of the file name that it does not care about. Here's a Nginx rule to show what I mean:
rewrite ^/style\..*\.css$ /style.css;
I use this rule to have file names such as style.42750cad6.css , which always points to a style.css file. The text in the middle changes when style.css changes. The difference between the first approach is that it does not use the request, so caching will work in more browsers.
source share