Tag: hooks
Defer Parsing of JavaScript in WordPress

It’s a common complaint when you run your WordPress site through any “page speed score” tool: “defer parsing of JavaScript” and/or “remove render-blocking JavaScript.” Today, building on an article Fred first wrote in 2015, I’m going to discuss a was to solve that. It’s been possible since WordPress 4.1, which introduced of a new filter, script_loader_tag. This filter lets us easily change the HTML markup of enqueued script elements—that is, of JavaScript files that were correctly added into a WordPress site using WordPress’s wp_enqueue_script function.
How to Include JavaScript Files on Your WordPress Site with wp_enqueue_script()

Want to know how to include a JavaScript file onto your WordPress site? In this Quick Quide we use an awesome WordPress function called wp_enqueue_script() that is the correct way to include JavaScript files in WordPress. Whether your JavaScript files are for Vue, React, JQuery, or something else, this is how you include JavaScript files in WordPress pages.
Writing a WordPress Plugin From Scratch: A Step-by-Step Tutorial

This WordPress plugin development tutorial captures the steps I went through on a real project, including the mistakes I made and how I debugged them.
How to Properly Modify JavaScript Files in a Parent Theme

I recently needed to modify a JavaScript file in a WordPress parent theme. The script was doing almost what I wanted, but not quite, so I wanted to make minor changes. In your case, you might want to entirely override a parent theme JavaScript file in your child theme, or even deactivate a parent theme JavaScript file altogether.
WordPress Template Tags: How They Show Post Content & More

WordPress template tags are a super-important and super-valuable part of WordPress, especially for theme development. They’re also one of the things I remember spending lots of time not quite getting as I was learning WordPress.
Off the Hook: Practical Uses of remove_action() and remove_filter()

Today’s article continues our discussion of WordPress’s Hooks system with a practical look at the direct opposite of add_action() and add_filter(): remove_action() and remove_filter().
Lesser-Known Features in WordPress 4.6
Drew Jaynes has a pretty neat post up about some features you may not have noticed in WordPress 4.6. I have to admit that I’d not been paying super close attentions to everyone’s release notes posts, but this stuff was almost completely new to me. The most significant to me (by far) of Drew’s list is the last:
Practical Uses of pre_get_posts

In WordPress, pre_get_posts is an action that makes it possible to modify an existing WP_Query, before that query is actually run. pre_get_posts offers some solutions that are more performant than writing a custom WP_Query, and enables solutions to other problems that would be quite difficult otherwise.
Adam Brown’s Hooks List
There’s not really a shortage of ways to find WordPress hooks, filters, functions, and more. It was actually Jeff Chandler’s story about Hookr.io — a new entrant into the field — that reminded me of this one which I remember from years ago. It’s not especially pretty, but it’s a deep resource that makes it easy to jump from a list of hooks to where they sit in the source once you get the hang of it.