Enqueue script only if page has an oembed
Well the first thing to consider is that the wp_enqueue_scripts action hook fires before the filters on the page/post content are run. So I would add a function to the wp action hook and test the content for oembeds there. add_action( ‘wp’, ‘your_oembed_test_function’ ); function your_oembed_test_function(){ //earliest reliable hook to get $post variable global $post; … Read more