What does "myscript.js?1234567" do?

Discussion in 'JavaScript' started by WebGyver, Jul 14, 2007.

  1. #1
    As much as I hate coming across as a blithering idiot, here I go:

    Recently, I noticed that some web developers are using something like the following syntax:

    <script src="/scripts/somefile.js?1634528" type="text/javascript"></script>
    Code (markup):
    What does this do? Obviously, the .js file is not going to read in the value after the "?" — but there must be some reason (or benefit) for doing this.

    Looking at the code inside the files that were referenced this way, there was nothing special about them. As expected, the value following ".js?" had no bearings on the JavaScript code at all.

    So what is this all about? I need to know, really.


    Thanks much.
     
    WebGyver, Jul 14, 2007 IP
  2. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #2
    Maybe is a method to avoid cached (old) version of that .js file. So, updating that variable, you're forcing the new version to be loaded on browser.
     
    ajsa52, Jul 15, 2007 IP
  3. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ajsa52 is probably right. Refresh the page and see if the number changes.
     
    MMJ, Jul 15, 2007 IP
  4. AsHinE

    AsHinE Well-Known Member

    Messages:
    240
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    138
    #4
    With mod_rewrite this somefile.js can be generated by php for example. But I don't see any reason to do this, maybe some kind of user tracking?
     
    AsHinE, Jul 17, 2007 IP