久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

為什么將 JavaScript 放在頁面的頁腳中?

Why put JavaScript in the footer of a page?(為什么將 JavaScript 放在頁面的頁腳中?)
本文介紹了為什么將 JavaScript 放在頁面的頁腳中?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

所以我最近從 ThemeForest 購買并下載了一個模板.我在本地服務器上設置了模板.我使用 codeigniter 生成了具有下拉菜單的導航.我將菜單中的所有內容都正確編碼.我只生成了標題并進行了測試,并意識到下拉菜單不起作用.我花了大約兩個小時試圖找出我的代碼出了什么問題.然后我終于意識到 JavaScript 文件包含在模板的頁腳中......我還沒有生成.

So I recently bought and downloaded a template from ThemeForest. I set up the template on my local server. I generated the navigation, which has dropdown menus, with codeigniter. I had everything in the menu coded correctly. I only had the header generated and went to test it out and realized the dropdown menus were not working. I spent about two hours trying to figure out what was wrong with my code. Then I finally realized that the JavaScript files were included in the footer of the template... which I had not yet generated.

所以我的問題是……為什么有人會將 JavaScript 文件放在 HTML 頁面的頁腳中?我認為 JS 只應該位于文件的標題中.對吧?

So my question is... why would someone put JavaScript files in the footer of an HTML page? I thought that JS was only supposed to be located in the header of the file. Right?

推薦答案

您可以通過多種方式將腳本文件加載到網頁.

There are different ways you could load a script file to a web page.

但是在頁面底部加載腳本有以下優點.

But loading scripts at bottom of you page have the following advantages.

  1. 不會阻止任何要加載的 DOM 內容.
  2. 所有 DOM 元素都可用于正在加載的腳本.
  3. 如果您使用第三方庫,例如 jQuery,則可以跳過 $(document).ready(function () {...});,因為 DOM 已經加載.
  1. Will not block any DOM content to be loaded.
  2. All the DOM elements will be available for the scripts that are being loaded.
  3. If you are using third-party libraries such as jQuery, you can skip the $(document).ready(function () {...}); as the DOM is already loaded.

希望這會有所幫助.

這篇關于為什么將 JavaScript 放在頁面的頁腳中?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 認為文檔“準備好之前,如何讓我的 jasmine 測試裝置加載?) - IT屋-程序員軟件開發技術
What do jasmine runs and waitsFor actually do?(jasmine 運行和等待實際上是做什么的?)
How to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模擬文件來更改 lt;input type=filegt; 的事件用于單元測試)
How to unit test a chained method using Jasmine(如何使用 Jasmine 對鏈式方法進行單元測試)
How do I inject $rootScope into an AngularJS unit test?(如何將 $rootScope 注入 AngularJS 單元測試?)
Jasmine - How to spy on a function call within a function?(Jasmine - 如何監視函數中的函數調用?)
主站蜘蛛池模板: gogo肉体亚洲高清在线视 | 婷婷五月色综合香五月 | 天堂久| 欧美a在线 | 亚洲第一在线视频 | 欧美9999| 日韩亚洲欧美一区 | 在线色网址 | 日产精品久久久一区二区福利 | 久久久91 | 免费观看av网站 | 好姑娘高清在线观看电影 | 国产精品一二三区 | 五月综合久久 | 天天天插 | 国产精品不卡一区 | 国产免费观看视频 | 国产精品久久久久久久免费大片 | 国产一区二区三区高清 | av片网| 国产精品久久久久久久久久久新郎 | 操久久| 午夜免费观看体验区 | 亚洲成人日韩 | 一区二区三区视频在线 | 亚洲精久久 | 人人99 | jizz视频 | 午夜网站视频 | 97伦理电影| 人人草人人干 | 日本国产精品视频 | 在线成人免费av | 天天看天天操 | 久久专区 | 日韩精品无码一区二区三区 | 五月网婷婷 | 一级黄片一级毛片 | 综合久久国产 | 国产在线小视频 | 欧美日韩综合 |