I have a html file in which i am loading multiple js files . I need to declare a variable n append to each of the script tag. how i can do that ? appending variable as parameter
            Asked
            
        
        
            Active
            
        
            Viewed 734 times
        
    -3
            
            
        - 
                    Why do you need that??? – A. Wolff Jul 27 '15 at 12:59
- 
                    @A.Wolff to keep the browser from caching... – brso05 Jul 27 '15 at 13:00
- 
                    @user2287714 What framework are you using? – brso05 Jul 27 '15 at 13:00
- 
                    So it should be handled server side – A. Wolff Jul 27 '15 at 13:00
- 
                    @A.Wolff yes probably but he could technically inject scripts using javascript/jquery... – brso05 Jul 27 '15 at 13:01
- 
                    @brso05 ya he could still add some timestamp, but he shouldn't – A. Wolff Jul 27 '15 at 13:02
- 
                    Possible dupe: http://stackoverflow.com/questions/118884/what-is-an-elegant-way-to-force-browsers-to-reload-cached-css-js-files – A. Wolff Jul 27 '15 at 13:03
1 Answers
0
            
            
        - This can be done from the server side as well as client side. Safest way to do it is from server side. Simply set a variable into session containing the current System date of the server and add it onto the page.
- If you wish to do it from client side, you need to look for all the script tags in your code with src attribute and append a variable containing the current date to it. You can call this piece of code for window.onload() or document.ready() as per your will.
 
    
    
        Aalok Mishra
        
- 176
- 1
- 11
- 
                    the thing is i cannot use current date and time because i have to update version number only when i m uploading new js file to server. so my version no was 1.0 then in next upload of js i need to version no 1.1 – Abhishek Sinha Jul 27 '15 at 13:36
