Difference between revisions of "WordPress and JavaScript"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(How it works)
Line 1: Line 1:
 
[[WordPress]] can include [[JavaScript]].  This is done with [[WordPress theme|WordPress themes]].
 
[[WordPress]] can include [[JavaScript]].  This is done with [[WordPress theme|WordPress themes]].
  
== How it works ==
+
== wp_enqueue_script() ==
  
...
+
WordPress has a function named <code>wp_enqueue_script()</code> which allows you to "enqueue" a script.
 +
 
 +
That is, the script is placed in a queue of activities which WordPress will perform as it generates the website.
 +
 
 +
You can use <code>wp_enqueue_script()</code> in two places:
 +
 
 +
* In <code>functions.php</code>
 +
* In a [[WordPress plugin]]
 +
 
 +
== functions.php ==
 +
 
 +
The optional <code>functions.php</code> contains custom PHP for a [[WordPress theme]].
 +
 
 +
<pre>
 +
 
 +
</pre>
  
 
== See also ==
 
== See also ==

Revision as of 07:31, 10 December 2015

WordPress can include JavaScript. This is done with WordPress themes.

wp_enqueue_script()

WordPress has a function named wp_enqueue_script() which allows you to "enqueue" a script.

That is, the script is placed in a queue of activities which WordPress will perform as it generates the website.

You can use wp_enqueue_script() in two places:

functions.php

The optional functions.php contains custom PHP for a WordPress theme.


See also

External links