javascript - How to add WordPress jQuery library to frontend -


i'm using below method inside wordpress admin use jquery library , working fine , don't need add source jquery library method.

 <script>         jquery(document).ready(function(){             // works inside wordpress admin without source         });    </script> 

but same method not work on front end wordpress form , make work i've add source of library?

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script>         jquery(document).ready(function(){           // need add jquery source          });    </script> 

why need add source of jquery library frontend? how can load wordpress jquery library frontend?

it works in admin, because there admin scripts have jquery dependency , wordpress includes jquery in order scripts work.

you should use wp_enqueue_script() function when adding scripts (not including them in scripts tags). notice $deps variable of function, if set array( 'jquery' ), wordpress include library you, script can use it.

if scroll down page can see libraries included in wordpress , handles used enqueue them.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -