HTML and CSS Reference
In-Depth Information
WHAT WENT WRONG?
The first copy of jQuery is included the WordPress way, while some-plugin includes jQuery as
you would on a static HTML page.
A number of JavaScript frameworks are included in WordPress by default, including:
Scriptaculous,
jQuery (running in noConflict mode ) ,
1
the jQuery UI core and selected widgets,
Prototype.
2
A complete list can be found in the Codex . On the same page are instructions for using
jQuery in noConflict mode 3
AVOIDING THE PROBLEM
WordPress includes these libraries so that plugin and theme authors can avoid this problem
by using the wp_register_script and wp_enqueue_script PHP functions to include
JavaScript in the HTML.
Registering a file alone doesn't do anything to the output of your HTML; it only adds the file to
WordPress's list of known scripts. As you'll see in the next section, we register files early on in
a theme or plugin where we can keep track of versioning information.
To output the file to the HTML, you need to enqueue the file. Once you've done this,
WordPress will add the required script tag to the header or footer of the outputted page. More
details are provided later in this article.
Registering a file requires more complex code than enqueueing the files; so, quickly parsing
the file is harder when you're reviewing your code. Enqueueing the file is far simpler, and you
can easily parse how the HTML is being affected.
For these techniques to work, the theme's header.php file must include the line <?php
wp_head();?> just before the </head> tag, and the footer.php file must include the line <?php
wp_footer();?> just before the </body> tag.
Search WWH ::




Custom Search