引入JavaScript文件的方法有以下幾種:
<script>
標簽引入外部JavaScript文件:<script src="script.js"></script>
<script>
// JavaScript code here
</script>
defer
屬性延遲加載JavaScript文件:<script src="script.js" defer></script>
async
屬性異步加載JavaScript文件:<script src="script.js" async></script>
<script>
元素的方式引入JavaScript文件:var script = document.createElement('script');
script.src = 'script.js';
document.head.appendChild(script);