Michael Tot Korsgaard
Michael Tot Korsgaard

Reputation: 4014

Create script tag with query string

I'm adding scripts to my index.html file dynamicly, when adding the scripts I also want to add a query string containing the file version.

for this I've done this

var src = 'app/core.js?201701051511',
    script = document.createElement('script');
script.type = 'text/javascript';
console.info('src : ', src)
script.src = src;

script.async = true;
document.getElementsByTagName('head')[0].appendChild(script);

However when I look in my browser console there's no querystring attached to the src of the generated scripts, how come?

Upvotes: 1

Views: 1183

Answers (1)

Lukas Liesis
Lukas Liesis

Reputation: 26403

Query works as should. If console which you are using is trimming query, maybe it's just configured that way. Here is screenshot from Chrome on OS X.

enter image description here

Upvotes: 3

Related Questions