HTML and CSS Reference
In-Depth Information
A Single Point Of Registration
Register your styles and scripts in a single block of code, so that when you update a file, you
will be able to go back and update the version number easily.
If you use different code in different parts of the website, you can wrap the logic around the
enqueue scripts.
If, say, your archive pages use different JavaScript than the rest of the website, then you might
register three files:
base JavaScript (registered as theme-base ),
archive JavaScript (registered as theme-archive ),
general JavaScript (registered as theme-general ).
Again, the base JavaScript adds nothing to the website. Rather, it is a group of default
functions that the other two files rely on. You could then enqueue the files using the following
function mytheme_enqueue_js (){
if ( is_archive ()) {
wp_enqueue_script ( 'theme-archive' );
elseif ( ! is_admin ()) {
wp_enqueue_script ( 'theme-general' );
add_action ( 'wp_print_scripts' , 'mytheme_enqueue_js' );
Using The Google AJAX CDN
While using JavaScript the WordPress way will save you the problem of common libraries
conflicting with each other, you might prefer to serve these libraries from Google's server
rather than your own.
Using Jason Penny's Use Google Libraries plugin is the easiest way to do this. The plugin
automatically keeps jQuery in noConflict mode.
Search WWH ::

Custom Search