0

I know you can't pass a parameter to a javascript file via variables after a URL (the way you can with php). - Passing parameters to JavaScript files - Can you pass URL parameters to a Javascript file?

But I am looking at live code from a production site that looks like this:

<script type="text/javascript" src="/sites/default/files/js/gmap_markers.js?f"></script>

If the ?f is not a parameter, then what is it doing?

Community
  • 1
  • 1
bernie2436
  • 22,841
  • 49
  • 151
  • 244
  • You haven't posted enough code to evaluate what the `f` is doing there. But it's probably a version designator. – Robert Harvey Dec 28 '13 at 00:03
  • We often use such parameters for cache busting at my work. It's not clear what ?f is doing, but it could be that. It could also be instructions to the whatever is serving the file. – Maus Dec 28 '13 at 00:03
  • @Maus A cache-buster needs a random (or at least changing) value as part of it. Otherwise, the URL will be found in the cache. – Barmar Dec 28 '13 at 00:08
  • 1
    Since gmap_markers.js is apparently *on your own server*, you or someone else with access to the server should know what it is doing. Ask whoever put it there. – Dagg Nabbit Dec 28 '13 at 00:09
  • @Barmar the cache was busted? perhaps? – Maus Dec 28 '13 at 00:34

1 Answers1

2

That's not a Javascript parameter; it's an URL parameter. It governs the manner in which the script itself is downloaded from the website.

<script type="text/javascript"
  src="https://maps.googleapis.com/maps/api/js?key=API_KEY&sensor=SET_TO_TRUE_OR_FALSE">
</script>

For example, a change in the letter of the parameter in the example in your question could be a change in the version of the Javascript. Changing the f to a g invalidates the browser cache, and forces the browser to download the new version.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501