All Posts by Email, Once a Week

Media Temple logo

CSS-Tricks is brought to you in part by Media Temple, the web hosting that we both use and recommend.

Scripts not loading in wordpress

  • # July 2, 2013 at 3:53 pm

    Hi, I am trying to load some scripts in wordpress the proper way but it is not working.
    In my functions.php file I have this:

    	add_action('wp_enqueue_scripts', 'ls_scripts');
    function ls_scripts() {
    if (!is_admin()) {
    wp_enqueue_style( 'ls-css', get_template_directory_uri() . '/css/liquid-slider.css');
    wp_enqueue_script( 'jquery-easing', get_template_directory_uri() . '/js/jquery.easing.1.3.js', array('jquery'), '', true );
    wp_enqueue_script( 'jquery-touchSwipe', get_template_directory_uri() . '/js/jquery.touchSwipe.min.js', array('jquery-easing'), '', true );
    wp_enqueue_script( 'jquery-ls', get_template_directory_uri() . '/js/jquery.liquid-slider.min.js', array('jquery-touchSwipe'), '', true );

    The css file is loading fine but the javascript files aren't loading at all but I cannot work out why.
    Can anybody help?

    Thanks in advance,

    # July 2, 2013 at 4:46 pm

    I have now made it work but only by getting rid of the reliance on jquery which obviosly isn’t ideal. Any ideas why it isn’t finding that jquery is loaded?

    This is my code for loading jquery:

    if ( !function_exists( 'core_mods' ) ) {
    function core_mods() {
    if ( !is_admin() ) {
    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery', ( "//" ), false);
    wp_enqueue_script( 'jquery' );
    add_action( 'wp_enqueue_scripts', 'core_mods' );


Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed