I am trying to load a Js Dynamic Audio Synth

by Ahmed Faruq   Last Updated July 11, 2019 22:08 PM - source

I saw a working Javascript Piano which I would like to implement on my page as a shortcode. I have already enqueued the Js file, and I can see it when I view my page source.

This is how I enquued it:

function chicken_wings_scripts() {

         wp_enqueue_script( 'audiosynth',  get_stylesheet_directory_uri() . '/js/audiosynth.js', array(), null, true );

My main challenge is I don't know how to call the code to display on frontend as the documentation is not a beginner friendly.

The documentation said "audiosynth implements a singleton class, AudioSynth"

Synth instanceof AudioSynth; // true

var testInstance = new AudioSynth;
testInstance instanceof AudioSynth; // true

testInstance === Synth; // true

This is a working example of the Piano https://keithwhor.com/music/

Tags : jquery

Answers 1

Your enqueue is missing the action.
Try this instead :

 * Enqueue audiosynth.
function chicken_wings_scripts() {

    wp_enqueue_script( 'audiosynth', get_theme_file_uri( '/js/audiosynth.js' ), array(), filemtime( get_theme_file_path( '/js/audiosynth.js' ) ), true );

add_action( 'wp_enqueue_scripts', 'chicken_wings_scripts' );
July 11, 2019 21:56 PM

Related Questions

How to reset, reinit wordpress wpColorPicker?

Updated August 02, 2017 09:08 AM

Sortable post using wp_update_post not updating

Updated March 28, 2017 20:08 PM