Javascript - inline vs external script - what's the difference?

后端 未结 4 1397
再見小時候
再見小時候 2020-11-27 21:39

I have a few snippets of javascript scattered about my pages - many are contained in my own .js files, however some of the stuff that I\'ve found online sits directly on the

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-27 22:11

    Generally there is no difference as indicated in the comments. But, if the snippet is embedded in the middle of the HTML in the page and it is not a function, it is executed immediately. Such script segments may have a difference in behavior when moved to a separate JS file when enough care is not taken.

提交回复
热议问题