{"id":6742254,"date":"2015-11-12T11:11:43","date_gmt":"2015-11-12T11:11:43","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/adding-custom-javascript\/"},"modified":"2016-08-30T20:11:44","modified_gmt":"2016-08-30T20:11:44","slug":"adding-custom-javascript","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/adding-custom-javascript\/","title":{"rendered":"Adding custom javascript"},"content":{"rendered":"<p>Hi,<\/p>\n<p>I am trying to add my custom javascript with this code in my functions.php from my child-theme.<\/p>\n<pre><code>function my_custom_scripts() {\n\twp_register_script( &#039;custom.js&#039;, get_stylesheet_directory_uri() . &#039;..\/js\/custom.js&#039;, array( &#039;jquery&#039; ) );\n\twp_enqueue_script(&#039;custom.js&#039;);\n}\n\nadd_action(&#039;wp_enqueue_scripts&#039;, &#039;my_custom_scripts&#039;);<\/code><\/pre>\n<p>It is loading my script, because I can see my console.log messages in the console, but it is not loading the jquery dependency. Why is this happening?<\/p>\n<p>I hope you guys can help me out with this weird problem.<\/p>\n","protected":false},"template":"","class_list":["post-6742254","topic","type-topic","status-publish","hentry","topic-tag-custom","topic-tag-how","topic-tag-javascript","topic-tag-jquery","topic-tag-js","topic-tag-to","topic-tag-wp_enqueue_script","topic-tag-wp_register_script"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6742254","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6742254\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=6742254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}