0

I was trying to load a parallax jQuery file but eventhough it's loaded in the index file, it doesn't trigger anything... Not even a simple alert('test')

functions.php

function theme_scripts() {
    wp_enqueue_style( 'theme-style', get_stylesheet_uri() );
    wp_enqueue_style( 'theme-jquery', "https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" );
    wp_enqueue_style( 'theme-parallax', get_template_directory_uri() . "/scripts/parallax.js");
    wp_enqueue_style( 'theme-mainjs', get_template_directory_uri() . "/scripts/main.js" );

}
add_action( 'wp_enqueue_scripts', 'theme_scripts' );

Example main.js

(function($) { 
  $(function() {
    alert('test')
  });
})(jQuery);

Lookin at console, there are no errors. Everything is loaded just fine.

1 Answer 1

2

wp_enqueue_style is used for CSS files, for scripts, it should be wp_enqueue_script.

https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, that was a stupid mistake! However, when I change it to wp_enqueue_script it breaks with error: Failed to load resource: net::ERR_EMPTY_RESPONSE
And which directory it tried to access? Now probably is just an issue with paths.
It fails on all three, so also the jQuery link which is just an URL

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.