New Landing How can we help? Themeforest Theme Support Dante load child-js after parent-js

Viewing 4 posts - 1 through 4 (of 4 total)
  • Posted in: Dante
  • #292765
    heinetz
    Member
    Post count: 63

    hi,

    I load my child.js via functions.php. It is loaded before parent-js.

    Is it possible to load child.js after parent.js?

    best,
    heinetz

    #292870
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please provide me login detail to check and resolve the issue.
    Thanks
    Mohammad

    #293131
    heinetz
    Member
    Post count: 63

    Hi Mohammad,

    I found out how to load the child’s script(s) after the parents script(s),
    but I didn’t help to solve my problem. I changed following code:

    
    	/* ENQUEUE CHILD-SCRIPTS
    	================================================== */
    	function sc_scripts() {
    		wp_enqueue_script( 'modernizr', 'https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js', array(), '1.0.0', true );		
    		wp_enqueue_script( 'prefixfree', 'https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js', array(), '1.0.0', true );		
    		wp_enqueue_script( 'swisscomply', get_stylesheet_directory_uri() . '/js/swisscomply.js', array(), '1.0.0', true );		
    	}
    	add_action( 'wp_enqueue_scripts', 'sc_scripts' );
    

    … in functions.php as follows:

    
    	/* ENQUEUE CHILD-SCRIPTS
    	================================================== */
    	function sc_scripts() {
    		wp_enqueue_script( 'modernizr', 'https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js', array(), '1.0.0', true );		
    		wp_enqueue_script( 'prefixfree', 'https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js', array(), '1.0.0', true );		
    		wp_enqueue_script( 'swisscomply', get_stylesheet_directory_uri() . '/js/swisscomply.js', array(), '1.0.0', true );		
    	}
    	add_action( 'wp_enqueue_scripts', 'sc_scripts', 20);
    

    What i’ve done was increasing the priority (third arg) in add_action

    But that didn’t solve my problem and i’ll start another thread.

    best,
    heinetz

    #293242
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please use this code instead of your code:-

    function sc_scripts() {
    		wp_enqueue_script( 'modernizr', 'https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js', array('sf-functions'), '1.0.0', true );		
    		wp_enqueue_script( 'prefixfree', 'https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js', array('sf-functions'), '1.0.0', true );		
    		wp_enqueue_script( 'swisscomply', get_stylesheet_directory_uri() . '/js/swisscomply.js', array('sf-functions'), '1.0.0', true );		
    	}
    add_action( 'wp_enqueue_scripts', 'sc_scripts', 20);

    Thanks 🙂
    Mohammad

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

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register