• Resolved Raju Mandapati

    (@mvpspl619)


    You’re using the wrong hook in this plugin. esc_url is designed for sanitizing urls and not for manipulating the HTML tags.

    You should use the hook for script_loader_tag instead. Attached is the sample code from wpmu site 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/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author David Clough

    (@cloughit)

    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

    (@mvpspl619)

    Is the update already release using the ‘script_loader_tag’ hook ?

    Plugin Author David Clough

    (@cloughit)

    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.