Performance vs plugin genrated javascript

When enqueuing a custom script, you can write them to load in the footer – prior to the </body> tag – making them non-render blocking for most purposes, but they may still come up as render-blocking on testing tools, since they literally must be executed before the page HTML can be considered fully loaded. Instead, … Read more

Why isn’t wp_enqueue_script(‘jquery-masonry’) working?

jQuery’s Masonry is bundled with WordPress. All you should need is wp_enqueue_script(‘jquery-masonry’); but note that the “slug” is jquery-masonry, not jquery_masonry. And be sure your are enqueueing on the wp_enqueue_scripts hook or later. function enqueue_masonry() { wp_enqueue_script(‘jquery-masonry’); } add_action(‘wp_enqueue_scripts’,’enqueue_masonry’); I’d guess that your problem has something to do with when you register/enqueue because loading core … Read more

Path to image in js with wp_localize_script [closed]

Aside from the fact that you shouldn’t use get_bloginfo(‘template_url’), but rather get_template_directory_uri() or it’s *_stylesheet_*() equivalent, it’s a JavaScript problem: The localized object shouldn’t be wrapped in quotes: // Wrong url : ‘svg_path.template_url+”/svg/plus.svg”‘, // Right: url : svg_path.template_url + “/svg/plus.svg”, When handling JavaScript, simply use console.log( svg_path ) in your script to see the output … Read more