<code>wp_enqueue_script( string $handle, string $src = '', array $deps = array(), string|bool|null $ver = false, bool $in_footer = false )</code>
很明顯最後一個參數 $in_footer 設定為 True 時,js 檔案會被加載到文檔底部。
wordpress 内置了 jquery 類庫。但預設是加載在頁面頭部的。
有兩種方式, 一種先是删除核心的 jquery 包,再引自定義的 jquery 包到底部:
另一種方式是有人讀了wp_enqueque_script 的代碼實作,如下:
是以正确的解決方案為:
<a href="https://developer.wordpress.org/reference/functions/wp_enqueue_script/">https://developer.wordpress.org/reference/functions/wp_enqueue_script/</a>
<a href="https://wordpress.stackexchange.com/questions/173601/enqueue-core-jquery-in-the-footer">https://wordpress.stackexchange.com/questions/173601/enqueue-core-jquery-in-the-footer</a>