Forums

[resolved] jQuery/Javascript not loading in custom theme, but only on my server! (11 posts)

  1. cinaed
    Member
    Posted 7 months ago #

    I've gone through the forums trying to solve this, but none of the solutions work for me...

    I have made a theme from scratch, using Masonry with InfiniteScroll included in the theme (not using InfiniteScroll as a WP plugin).

    The thing is: It all worked fine when setting up the theme locally using MAMP. And it all worked fine on my personal site (http://www.cinaed.net/wp)
    However, when setting up the proper site for my studio (on a temporary URL - might this be the issue?) the scripts are not loading.

    I've used <?php wp_enqueue_script('jquery'); ?> to load jQuery, and have used relative paths to load the other scripts. I have even used $j=jQuery.noConflict(); to set up my scripts.

    Any idea why the scripts are not loading on that specific server, when they worked just fine on the 2 others?

    The site in question is found at http://kolonihaven-no.web.nsn.no/

  2. Marventus
    Member
    Posted 7 months ago #

    Hi,

    I see what you mean: in Cinaed, I can see the call to the jquery 1.6.1 script, but in kolonihaven it is not being called.
    However, both sites seem to behave very similarly and I can't see any JQ effects missing from the affected site.
    Have you tried unregistering WP's jQuery and using google's CDN instead, as indicated in the wp_enqueue_script Codex article? The code WP supplies for that is:

    <?php
    function my_scripts_method() {
        wp_deregister_script( 'jquery' );
        wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js');
        wp_enqueue_script( 'jquery' );
    }    
    
    add_action('wp_enqueue_scripts', 'my_scripts_method');
    ?>

    You would of course have to tweak that a bit to link to the 1.6.1 version (assuming you are using the same version on both sites).

  3. j@revive
    Member
    Posted 7 months ago #

    I've had probs with jQuery enqueue too. In fact it has never worked for me. I use XAMP as local server and it doesn't work. Neither does it work on my live sites. Have posted same issue before and someone always says it works fine, I must be doing something wrong. Anyway I just include a jquery version in my theme and call it. Not as good but at least reliable.

  4. Marventus
    Member
    Posted 7 months ago #

    Yeah, I was going to tell you that if you can't make enqueue_script work, that you should just call it manually from your template files (preferably footer.php, or if not header.php).
    However, make sure jquery is not being called by WP as well.

  5. cinaed
    Member
    Posted 7 months ago #

    I tried using Google's CDN, but no change.
    Seems like the proble is in loading the masonry and infinitescroll scripts...

    Any ideas?

  6. Marventus
    Member
    Posted 7 months ago #

    Actually, Masonry and Infinite Srcoll are loading just fine, on lines 58 to 60 of your markup.
    What I still don't see is a call to the jquery script, which, if I'm not mistaken, is needed by both Masonry and Infinite Scroll in order to function.
    Can you paste in your reply the code you are using to call jquery? If wp_enqueue_script is not working, try loading jquery from Google's CDN directly from either your footer.php or header.php files.

  7. Le-Pixel-Solitaire
    Member
    Posted 7 months ago #

    Quick infos: since you're using Scriptaculous and jQuery at the same time, the bug could be found between them: check if you're using the latest version of both librairies.

    Even more, while using the noConflict() concept of jQuery remind yourself to "call the scripts" in a specific order: all the stuff related to jQuery first (the library followed by the plugins followed by the custom scripts...) then the ones related to Scriptaculous (in the same manner than the jQuery ones).

  8. Marventus
    Member
    Posted 6 months ago #

    Hi,

    Were you able to figure this out? If so, could you please mark this topic as resolved?

    Thanks!

  9. cinaed
    Member
    Posted 6 months ago #

    Solution was to call jQuery like this:
    <script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>

    No wp_enqueue...

  10. Marventus
    Member
    Posted 6 months ago #

    Yep, that's what I meant in one of my previous posts:

    If wp_enqueue_script is not working, try loading jquery from Google's CDN directly from either your footer.php or header.php files.

    I'm glad its working now, and thanks for marking this as resolved.

  11. alturo
    Member
    Posted 5 months ago #

    I'm experiencing the same issue on my site but I can't get it working even calling jQuery like you suggest <script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script> neither <?php wp_enqueue_script("jquery"); ?>

    My site is madridmemata.es, I need to call two js, jQuery and other called taber.js but I'm lost I really appreciate any tip !!

Reply

You must log in to post.

About this Topic