Where should I declare JavaScript files used in my page? In <head></head> or near </body>?

后端 未结 12 955
后悔当初
后悔当初 2020-11-27 15:07

I was reading a tutorial and the author mentioned to include Javascript files near closing body tag () in HTML.

I was wonderi

12条回答
  •  庸人自扰
    2020-11-27 15:30

    The Place of the ...

    A better option is to combine all the files:

    
    
    
        My App
        
    
    
        ...
    
    
    

    And the best option is to put the combined script at the very end of the page:

    
    
    
        My App
    
    
        ...
        
    
    

    “JavaScript Patterns, by Stoyan Stefanov (O’Reilly). Copyright 2010 Yahoo!, Inc., 9780596806750.”

提交回复
热议问题