Title: Wrong hook filter usage
Last modified: September 1, 2016

---

# Wrong hook filter usage

 *  Resolved [Raju Mandapati](https://wordpress.org/support/users/mvpspl619/)
 * (@mvpspl619)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/wrong-hook-filter-usage/)
 * You’re using the wrong hook in this plugin. [esc_url](https://codex.wordpress.org/Function_Reference/esc_url)
   is designed for sanitizing urls and not for manipulating the HTML tags.
 * You should use the hook for [script_loader_tag](https://developer.wordpress.org/reference/hooks/script_loader_tag/)
   instead. Attached is the sample code from [wpmu site](https://premium.wpmudev.org/forums/topic/using-apply_filtersscript_loader_tag-to-add-async-to-loading-js)
   that shows how to add attributes to the script tag.
 *     ```
       add_filter( 'script_loader_tag', function ( $tag, $handle ) {
       return preg_replace("/(><\/[a-zA-Z][^0-9](.*)>)$/", " async $1 ", $tag );
       }, 10, 2 );
       ```
   
 * Please implement it soon and push a new version if you’re actively developing.
   Or I’d love to contribute to the plugin as a developer.
 * [https://wordpress.org/plugins/async-javascript/](https://wordpress.org/plugins/async-javascript/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [David Clough](https://wordpress.org/support/users/cloughit/)
 * (@cloughit)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/wrong-hook-filter-usage/#post-7499514)
 * Hi,
 * This was something that was on the development checklist. In actual fact it was
   using the ‘clean_url’ hook and as it is known that this hook has been depreciated
   it was planned to be replaced in a future release.
 * The latest version of Async JavaScript uses the ‘script_loader_tag’ function.
 *  Thread Starter [Raju Mandapati](https://wordpress.org/support/users/mvpspl619/)
 * (@mvpspl619)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/wrong-hook-filter-usage/#post-7499525)
 * Is the update already release using the ‘script_loader_tag’ hook ?
 *  Plugin Author [David Clough](https://wordpress.org/support/users/cloughit/)
 * (@cloughit)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/wrong-hook-filter-usage/#post-7499526)
 * Yes, the latest version of Async JavaScript uses the ‘script_loader_tag’ function.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Wrong hook filter usage’ is closed to new replies.

 * ![](https://ps.w.org/async-javascript/assets/icon-128x128.png?rev=1839260)
 * [Async JavaScript](https://wordpress.org/plugins/async-javascript/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/async-javascript/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/async-javascript/)
 * [Active Topics](https://wordpress.org/support/plugin/async-javascript/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/async-javascript/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/async-javascript/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [David Clough](https://wordpress.org/support/users/cloughit/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/wrong-hook-filter-usage/#post-7499526)
 * Status: resolved