• Hi,

    I am having a hard time to figure out how to enqueue a script to create a burst effect when hovering a link.

    These are my very first steps on theme creation and javascript.

    I have enqueued the mo.js script from its cdn and I am able to display its effect on links ONLY WHEN using a gutenberg custom/html block with the js code inside. Of course, this works only on the post where the custom/html resides.

    I have tried to follow some tutorials here and there :

    I am using underscores theme as a starting point :

    /**
     * Enqueue scripts and styles.
     */
    function capables_scripts() {
    	wp_enqueue_style( 'capables-style', get_stylesheet_uri(), array(), _S_VERSION );
    	wp_style_add_data( 'capables-style', 'rtl', 'replace' );
    
    	wp_enqueue_script( 'capables-navigation', get_template_directory_uri() . '/js/navigation.js', array(), _S_VERSION, true );
    	wp_enqueue_script('mojs', 'https://cdn.jsdelivr.net/mojs/latest/mo.min.js', array(), _S_VERSION, true );
    
    	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
    		wp_enqueue_script( 'comment-reply' );
    	}
    }
    add_action( 'wp_enqueue_scripts', 'capables_scripts' );
Viewing 1 replies (of 1 total)
  • Thread Starter tskpbls

    (@tskpbls)

    I’d be glad if someone could try to explain me why, if I add a js file called test under my theme and use :

    function my_custom_js() {
        echo '<script type="text/javascript" src="js/test.js></script>';
    }
    add_action( 'wp_footer', 'my_custom_js' );

    under functions.php

    it does not work, but if I paste directly my test.js code inside wp_footer it’s working correctly. What I am doing wrong?

    • This reply was modified 2 years, 10 months ago by tskpbls.
Viewing 1 replies (of 1 total)
  • The topic ‘enqueue mo.js script’ is closed to new replies.