Search code examples
javascriptcurly-bracescurly-brackets

What is the meaning of curly brackets at the end of a js file reference?


I have seen a code like this and wonder what that curly brackets for, is it some kind of argumant pass?

<script type="text/javascript" src="some_script.js?{0}"></script>

Solution

  • In a URL, after the question mark ? is the query string. This is where you specify parameters for the server.

    In this case since those brackets aren't encoded (as %7B0%7D), I suspect you're actually seeing this in the context of a template engine, and {0} is a random number. This is commonly used to avoid caching files, since with the random number you effectively have a new URL every time. I don't know what template engine you're using... several use this notation.