Load same javascript file two times on same page

Discussion in 'Programming' started by cryoffalcon, May 15, 2012.

  1. #1
    I have a question is it bad or what are the disadvantages of doing what I am going to explain.
    I want to put the same javascript file two time in the same page e-g
    <script type="text/javascript" src="http://www.mydomain.com/javascript.js"></script>
    
    <script type="text/javascript" src="http://www.mydomain.com/javascript.js"></script>
    Code (markup):
    Now many people will ask why would I want to do that, well the reason is that I am using blogger and blogger doesn't let me see all code from which the page is made rather split it into two parts named as POSTS and EDIT HTML. So I am going to place this script in those both areas but at the end when the page loads it is actually going to two the same script two times which is not error.
    Another question would be why am I not using same script in one place rather than two places if at the end the page code is going to become one. Well the answer would be because that script is used by other scripts too so I CAN'T CHANGE THE LOCATION if I do so, then the script stops working.
     
    cryoffalcon, May 15, 2012 IP
  2. perfect_element

    perfect_element Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    No, there is no problem.

    Of course it would be better to avoid it, but there will be no performance hit.

    The second file will probably be ignored and even if the browser were to download it again it would get it from the cache.

    Just make sure that the files content is the same.
     
    perfect_element, May 15, 2012 IP