ThemeShaper Forums » Thematic

[closed]

How to add jQuery?

(7 posts)
  • Started 3 years ago by Biofobico
  • Latest reply from Biofobico
  • This topic is resolved

Tags:

  1. Biofobico
    Member

    I'm new to wordpress hence my noob question. How can i add jQuery library to Thematic?
    On static sites i create a folder and put my jquery library inside along with a custom.js file with the javascript implementations and then called it in the <head> of the site after the css.

    Whats the best practices to do this with wordpress and thematic?

    And sorry for the really noob question.

    Posted 3 years ago #
  2. jQuery and many other JS libraries are included with WordPress and the Thematic theme has included jQuery in the head already.

    For more info: http://codex.wordpress.org/Function_Reference/wp_enqueue_script

    Look here also: http://forums.themeshaper.com/topic/best-way-to-add-additional-jquery-scripts

    For more discussions: http://forums.themeshaper.com/tags/jquery

    -Gene

    Posted 3 years ago #
  3. Biofobico
    Member

    Thanks Gene. Problem solved :)

    Posted 3 years ago #
  4. Hi,

    let me add one snippet that I use in all of my child themes to add jQuery and to clean up behind some 'stupid' plugins ;)

    function re_init_jQuery() {
    	if (!is_admin()) {
    		wp_deregister_script('jquery');
    		wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
    	}
    }
    add_action('init', 're_init_jQuery');

    Chris

    Posted 3 years ago #
  5. Biofobico
    Member

    Sorry about the dumb question Chris, but whats the purpose of that code snippet?

    Posted 3 years ago #
  6. Hi,

    this code snippet is used for WordPress 2.9.x. It'll exchange the standard jQuery version and all versions registered by strange plugins against a newer one, but only for the frontend. jQuery 1.4.2 is causing some glitches in the WP backend.

    Just in case that you need jQuery only on certain pages or for certain templates, you can wrap the wp_register_script into additional if-clauses. This will reduce the load time for your blog.

    Chris

    Posted 3 years ago #
  7. Biofobico
    Member

    Thanks for the clarification Chris.

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.