• Hello,

    I am using the plugin ‘ilightbox’. I have bene on the developers website and have established i need to load custom script 5 shown at the below URL:
    https://www.ilightbox.net/faq.html

    I have a child theme which has a custom.js file. I can get the file to load but the script errors with the following:

    .iLightBox is not a function

    I have tried to contact the developer but not getting any response. Someone suggested it was because the custom.js theme was being loaded before the jQuery lib or the ilightbox plugin files.

    Can someone tell me how to load my custom.js file at the correct place or even last ? At least then i can identify if the actual script is the issue or the loading of my file is.

    Website URL is below if required:
    https://www.complete-models.com/uncategorized/16-alien-figure/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Loading scripts and styles in themes should be done using the wp_enqueue_scripts method outlined here:

    https://codex.www.ads-software.com/Function_Reference/wp_enqueue_script

    Part of this allows you to pass dependancies for scripts which means they are loaded before. Take a look at the above URL.

    Thread Starter Jld142

    (@jld142)

    @mark Wilkinson, thank you for the reply.

    I have checked the URL but must admit i am a little confused with how to actually call my file at the correct time.

    This is my current code:

    /* Link JavaScript file */
    function custom_scripts() {
    	wp_register_script( 'custom-script', get_stylesheet_directory_uri() . '/assets/js/custom.js', array() , false, true );
    	wp_enqueue_script( 'custom-script' );
    }
    add_action( 'wp_enqueue_scripts', 'custom_scripts', 99 );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Call custom.js child theme file once jQuery lib has been loaded’ is closed to new replies.