WordPress.org

Ideas

Non-blocking Asynchronous wp_enqueue_script

  1. gewinnspiele
    Member

    12345

    @Paris Holley

    Great! Thank you for the plugin! It worked for me.

    Posted: 2 years ago #
  2. jamesdlow
    Inactive

    The first time I need it, I was really surprised this wasn't built in. We shouldn't really have to be reduced to filters and hacks to get this attribute added.

    Hope they can add this update soon!

    Posted: 1 year ago #
  3. Ralf Koller
    Member

    12345

    If an option for the async attribute would be added it would be welcome as well too add an option for defer alongside as well

    Posted: 1 year ago #
  4. swdeveloper
    Member

    If your wordpress version is 4.1 or higher you can use 'script_loader_tag' filter. For example:

    function change_to_async($tag, $handle) {
    'your-js-script' == $handle ? str_replace( ' src', ' async="async" src', $tag ): $tag;
    }
    
    add_filter('script_loader_tag', 'change_to_async');
    Posted: 3 months ago #
  5. GreatBlakes
    Inactive

    12345

    I'm also using the custom string replace method myself with success, but it feels so hacky.

    I'm still hoping that WordPress core will have an implementation of this in the future. I'm honestly surprised it has gone this long without.

    Posted: 1 month ago #
  6. I use the plugin and it works very well. Thank you so much.

    Posted: 1 month ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    42 Votes
  • Status

    This idea is under consideration