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
- 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
- Solutions for generating dynamic javascript / CSS
- 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
- The difference between calling wp_enqueue_scripts to load scripts and styles in custom theme
- 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?
- 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
- 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
- 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
- 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
- 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 to fix : Uncaught ArgumentCountError: Too few arguments to function? [closed]
- 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
- 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?
- Customizer Image-Picker Preview Not Working
- Does any JavaScript file load automatically for index.php file?
- How would I get this to work – send to post from thick box
- Theme customizer live preview JS- Trying to bind to an html image url without luck
- enqueue script if page is not equal to
- Set start page depending on screen width [closed]
- Paginated WP_Query doesn’t return 404’s, even when posts don’t exist
- Using wp_enqueue_script with social media buttons?
- How to reuse parts of WordPress site e.g. header, footer, part of header for multiple WordPress sites?
- JavaScript file successfully registered but does not render correctly
- Enqueue script/style with multiple GET parameters
- What is The Best Way to Make Parallax header effect for wordpress theme ?? pure CSS or using JavaScript? [closed]
- WP site makes mobile browser crash for high memory usage
- How can i move my product name & price from below thumbnail to be the rollover content in Avada & Woocommerce?
- jQuery Snippet Not Working on WordPress Site [closed]
- WP Customizer get control value on change
- Execute javscript when theme customizer loads (autosave issue)
- When trying to run build script with gutenberg (with SVG import) – Error: Plugin name should be specified
- Smooth Scrolling Animation of Image Between Two Containers (Elementor) Using JavaScript and GSAP
- How to add group-row to InnerBlock template?
- Javascript localization doesn’t load. How to Internationalize javascript without plugin?