sequence of javascript tag

Discussion in 'JavaScript' started by tanvirtonu, Jun 19, 2009.

  1. #1
    I just want to know if the following sequence of javascript code is possible.If possible what are the drawbacks and what are the considerations I should remember.

    
    <script type="text/javascript" src="someFile.js"></script>
    
    <script type="text/javascript">
    // code goes here
    </script>
    
    <script type="text/javascript" src="anotherFile.js"></script>
    
    <script type="text/javascript" src="anotherFile.js"></script>
    
    <script type="text/javascript">
    // code goes here
    </script> 
    Code (markup):

     
    tanvirtonu, Jun 19, 2009 IP
  2. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    might be a little bit slower with multiple javascript files but not significantly, plus seperating the code into seperate files will make debugging slighly easier if you don't have a proper debugger.
     
    camjohnson95, Jun 20, 2009 IP
  3. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #3
    just remember this though:

    # Inline scripts block rendering in the entire page;
    # Inline scripts block downloads;
    # Stylesheets followed by inline scripts can make your pages twice as slow;

    (championed by Steve Souders (author of YSlow), who now works at google on web performance).
     
    dimitar christoff, Jun 20, 2009 IP