• Resolved David Calhoun

    (@dpcalhoun)


    Hi.

    I’m a little flustered with this, because I’d think I could figure this out on my own. But I’m having trouble getting Javascript loaded into a WordPress site. I’ve read up on using the “wp_enqueue_script” function to get jQuery loaded, and that seems to be woring alright.

    What I can’t get working, is loading my specific Javascript file I need. I’m using the following after the “wp_head” function:

    <script type="text/javascript" src="js/scripts.js"></script>

    When I look at the loaded page’s source, it shows the script calling in jQuery, but doesn’t show the script calling in my specific “scripts.js” file. It’s not even a part of the page. I’ve tried inserting the “bloginfo(‘template_directory’)” in there as well:

    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/scripts.js"></script>

    What am I doing wrong?

    This is the Javascript slider I’m trying to incorporate into my page: https://www.dreamcss.com/2009/04/create-beautiful-jquery-sliders.html

Viewing 3 replies - 1 through 3 (of 3 total)
  • I am having the same problem. What did you do to fix this issue?

    Thread Starter David Calhoun

    (@dpcalhoun)

    I honestly don’t remember, I think I overlooked something small. I’ve been able to use Javascript fine on many sites since then. If you are still having trouble with this, comment back and I’ll try to help you out.

    Hi,

    I’m also having an issue loading JS from a plugin I’m building. As far as I can tell I have correctly queued the JS.

    I think the issue is that the JS files are not being ignored by the router (template-loader)/,htaccess and are causing a 404 when the url fails to resolve. Just theory at the moment.

    Bit of a weird one but probably related to the slightly mad way that WP does certain things.

    Ian

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Loading Javascript Files’ is closed to new replies.