1

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?

3
  • I just try the code and there is the query string: That's the generated html, at the bottom of the head <script type="text/javascript" src="app/core.js?201701051511" async=""></script> Commented Jan 5, 2017 at 14:19
  • What shows up in your console? Commented Jan 5, 2017 at 14:20
  • This question appears to be off-topic (#2) as it's not reproducible. Please update your question to include a minimal reproducible example. Commented Jan 5, 2017 at 14:26

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.