How to register and enqueue JavaScript files without breaking plugin dependencies?

I would use jquery-masonry included in WordPress core: function my_scripts() { wp_enqueue_script( ‘jquery-masonry’, true ); } add_action( ‘wp_enqueue_scripts’, ‘my_scripts’ ); If you really need the standalone masonry library, you should use your “first way” but I would not use “my_masonry” as handle for the script, I would use “masonry” if you have not modified the … Read more

Custom Plugin – CSS works, JS doesn’t

Would you please try below code to your plugin page. if the script file is your plugin root directory. function plugin_adding_scripts() { wp_register_script(‘my_test_script’, plugins_url(‘testscript.js’, __FILE__), array(‘jquery’),’1.1′, true); wp_enqueue_script(‘my_test_script’); } add_action( ‘wp_enqueue_scripts’, ‘plugin_adding_scripts’ ); Also: http://blog.aztora.com/add-css-js-into-wordpress-plugin/