Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #845325

    Hello,

    how could I place my custom Child theme Javascript-file “my-custom-js.js'” after the avia.js file?
    At the moment I use in Child theme functions.php:

    function add_my_script() {
        wp_enqueue_script( 'my-custom-script', get_stylesheet_directory_uri() . '/js/my-custom-js.js', array('jquery'), '1.0.1', true );
    }
    add_action( 'wp_enqueue_scripts', 'add_my_script' );
    

    The result is:

    <footer> 
      bla bla bla
    </footer>
    <script type='text/javascript' src='https://mysite.com/wp-content/themes/enfold-child/js/my-custom-js.js?ver=1.0.1'></script>
    <script type='text/javascript' src='https://mysite.com/wp-content/themes/enfold/js/avia.js?ver=4.1'></script>
    <div id="fb-root"></div>
    </body>
    </html>
    

    I need the sequence order another way round: first avia.js, then my-custom-js.js, because my-custom-js.js overrides some of jQuery events that are defined inside of avia.js.

    P.S.: I don’t want to copy the whole avia.js file into my Child Theme and adjust it there, because there the avia.js file won’t be receiving any automatic updates anymore – if I understood it correctly.

    Best regards
    Adele

    #845352

    Hey Adele!

    Please use the code as following

    function add_my_script() {
        wp_enqueue_script( 'my-custom-script', get_stylesheet_directory_uri() . '/js/my-custom-js.js', array('jquery'), '1.0.1', true );
    }
    add_action( 'wp_enqueue_scripts', 'add_my_script', 10);

    Regards,
    Yigit

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.