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 code. Also, use the correct version number of the library (I think your are not really using 1.0.0).
Related Posts:
- Is there a way to set the order of wp_footer hooked functions?
- Including Javascript options
- jQuery not available to other scripts
- Enqueued JavaScript is not working
- add jquery file if a certain page is included
- How do I get my theme scripts to load in a custom theme built from Bootstrap
- wp_deregister_script was called incorrectly
- Theme now uses require.js and enqueue script no longer works
- How to Use Webpack with WordPress Script Modules and Enqueue a Custom Class
- What is the preferred way to add custom javascript files to the site?
- Does the functions.php file ever get called during an AJAX call? Debug AJAX
- theme path in javascript file
- How to include jQuery and JavaScript files correctly?
- pass object/JSON to wp_localize_script
- Solutions for generating dynamic javascript / CSS
- How to enqueue script if widget is displayed on page?
- wp_enqueue_scripts, wp_register_scripts, wp_print_scripts: i’m confused
- Register and enqueue conditional (browser-specific) javascript files?
- Proper, exhaustive documentation for wp.editor etc
- Any alternate TinyMCE4 themes / subthemes?
- Why I can’t add a CSS style in this WordPress theme?
- The difference between calling wp_enqueue_scripts to load scripts and styles in custom theme
- jQuery in header or footer
- Google Maps not displaying in wordpress using Google Maps Javascript API
- Trigger Customizer saving process with Javascript only
- What can I hook into after_setup_theme?
- What does “Do not deregister the jquery script in the administration area” mean?
- wp_register_script multiple identifiers?
- What is the best practice for customizing a plugin’s JavaScript/jQuery?
- How do you enqueue script tags for ReactDOM in WordPress’ functions.php?
- using wp_enqueue_script to attach jquery-ui
- Use js script from one plugin in another plugin
- Changing the entire control choices using wp.customize with JavaScript
- How to Change CSS Variable value in Theme Customizer Live Preview
- Modifying JS files in Child-theme
- Dequeue / Deregister script and replace it with a new plugin
- Enqueued Stylesheets Effecting Admin Styles
- Can’t get JS code to work with shortcode
- wp_enqueue_script being ignored in custom theme
- Whats the safest way to output custom JavaScript and Css code entered by the admin in the Theme Settings?
- WordPress Customizer Control with React
- Getting jquery to work with custom theme
- How to configure wordpress to work with Vuejs with SSR and without hashbang
- Is it safe to enqueue a font style without putting http or https?
- How to hook CSS file according to theme selection in the customizer section
- Adding wp_enqueue_media(); causes problem
- How to correctly add JQuery in a WP theme?
- using wordpress without javascript
- Is there a filter for enqueue script to strip the type=”text/javascript” property
- Is my approach to enqueue styles inefficient?
- Deregistering a script in WordPress seems impossible
- functions.php not hooking up with style.css
- way to include own functions independent of theme
- How to To Filter wp_enqueue_script() Scripts on Some Pages
- React JSX in WordPress Plugin Development
- JavaScript Change focus to password field login page being reset
- Why won’t my scripts load?
- How to add Bootstrap Tour JavaScript to WordPress Admin Panel Dashboard Widget
- Difficulty loading jQuery with wp_enqueue_script
- When to use add_action when registering/enqueuing scripts
- How to make Isotope and WordPress work together?
- Single page site with history.js
- Is there a way to check for an attribute of a script when using script_loader_tag?
- How to add material design css in wordpress and woocommerce
- Use second time navigation.js in underscores [closed]
- Can´t access child theme´s scripts dependencies found in parent
- Theme Javascript.php Overwritten Nightly [closed]
- How to: JQuery multiple wordpress media uploader buttons in the same options page?
- How to get javascript slider to work! [closed]
- How to modify default controls in WordPress theme customizer
- How to enqueue javascript for WP Customize options sidebar?
- Theme Customizer not loading JS for live preview
- My jQuery is enqueued properly. So why isn’t it working?
- Scripts not loading through function Method in WordPress Theme
- Overide enqueue in non plugable function via child theme
- wp_enqueue_script not working?
- admin_enqueue_scripts not rending JS file correctly
- How can I wrap all blog posts image with
- How to fix : Uncaught ArgumentCountError: Too few arguments to function? [closed]
- White screen when attaching css to function.php
- WordPress theme resource won’t load over VPN
- How to enqueue a script which is type module without using script_loader_tag filter?
- pass wordpress template directory into ajax url call
- theme-independent CSS/JS files
- Add crossorigin to SCRIPT tag
- Javascript development in Custom Themes
- Custom jquery not code not working in wordpress
- Failing to load my script files in wordpress! i can’t figure out what i’m doing wrong
- enqueuing external and internal js and css in wordpress did not work with owl.js animate.css
- Adding google fonts to WordPress theme
- getBoundingClientRect() showing different values on load vs scroll
- wordpress script_loader_tag in function.php
- How to diagnose wp-env environment problem
- how can i remove js file from my footer in wordpress
- Find out the reason that the Styles and scripts in the theme are loading properly in localhost but Not in server after deploying
- How to enqueue scripts properly with ES6 webpack?
- Ajax Comment Upvotes – Votes don’t always register
- change background image on scroll
- Enqueue script for development purposes only?
- Customizer Image-Picker Preview Not Working