Title: JS ordering/async
Last modified: September 7, 2017

---

# JS ordering/async

 *  Resolved [Marius](https://wordpress.org/support/users/kodeks/)
 * (@kodeks)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/js-ordering-async/)
 * I’m wondering if there is any way to set the order of merged JS-files. Right 
   now jQuery is loaded after another script which requires jQuery.
 * Is there also any way to set the script to load asynchronously?

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

 *  Plugin Author [launchinteractive](https://wordpress.org/support/users/launchinteractive/)
 * (@launchinteractive)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/js-ordering-async/#post-9477878)
 * Hi, MMR lets WordPress handle the ordering of the includes.. but you can modify
   it by dequeuing and enqueuing in your functions file. There is also some other
   plugins that allow you to re-order your scripts.
 *  Plugin Author [launchinteractive](https://wordpress.org/support/users/launchinteractive/)
 * (@launchinteractive)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/js-ordering-async/#post-9477894)
 * Also, adding async or defer can be handled using this code:
 *     ```
       function add_async_attribute($tag, $handle) {
           if ( !in_array($handle, array('js-0','js-1','jquery')) ) {
               return $tag;
           }
           return str_replace( ' src', ' async="async" src', $tag );
       }
       add_filter('script_loader_tag', 'add_async_attribute', 10, 2);
       ```
   
 * Note: You will need to modify the handles to match your site.. MMR creates handles
   like this: js-[0 BASED POSITION]
 * Also, if you want jquery to load before your script you should add jquery as 
   a dependancy in wp_enqueue_script/register_script

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

The topic ‘JS ordering/async’ is closed to new replies.

 * ![](https://ps.w.org/merge-minify-refresh/assets/icon.svg?rev=3414776)
 * [Merge + Minify + Refresh](https://wordpress.org/plugins/merge-minify-refresh/)
 * [Support Threads](https://wordpress.org/support/plugin/merge-minify-refresh/)
 * [Active Topics](https://wordpress.org/support/plugin/merge-minify-refresh/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/merge-minify-refresh/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/merge-minify-refresh/reviews/)

## Tags

 * [async](https://wordpress.org/support/topic-tag/async/)
 * [Merge](https://wordpress.org/support/topic-tag/merge/)
 * [order](https://wordpress.org/support/topic-tag/order/)

 * 2 replies
 * 2 participants
 * Last reply from: [launchinteractive](https://wordpress.org/support/users/launchinteractive/)
 * Last activity: [8 years, 8 months ago](https://wordpress.org/support/topic/js-ordering-async/#post-9477894)
 * Status: resolved