Title: Problem with &#8220;defer&#8221;
Last modified: May 9, 2018

---

# Problem with “defer”

 *  Resolved [espacemusculation](https://wordpress.org/support/users/espacemusculation/)
 * (@espacemusculation)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/problem-with-defer/)
 * Hello,
 * I have a problem with the last update,
 * -> L’attribut “defer” ne peut pas apparaître dans la balise “amphtml engine v0.
   js script”
 * Could you help me please ?
 * thanks you
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fproblem-with-defer%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/problem-with-defer/#post-10264455)
 * [@espacemusculation](https://wordpress.org/support/users/espacemusculation/) 
   [@humoba](https://wordpress.org/support/users/humoba/)
 * This was also mentioned in [https://wordpress.org/support/topic/numerous-validation-errors-in-google-console/](https://wordpress.org/support/topic/numerous-validation-errors-in-google-console/)
 * What plugins do you have active? You probably have some theme or plugin that 
   includes some logic to add the `defer` attribute for performance when it shouldn’t(
   since it already has `async`).
 *  Moderator [Jan Dembowski](https://wordpress.org/support/users/jdembowski/)
 * (@jdembowski)
 * Forum Moderator and Brute Squad
 * [8 years, 5 months ago](https://wordpress.org/support/topic/problem-with-defer/#post-10265668)
 * [@billbennett](https://wordpress.org/support/users/billbennett/) If you need 
   support then per the forum guidelines please start your own topic.
 * [https://wordpress.org/support/guidelines/#post-in-the-best-place](https://wordpress.org/support/guidelines/#post-in-the-best-place)
 * You can do so here.
 * [https://wordpress.org/support/plugin/amp/#new-post](https://wordpress.org/support/plugin/amp/#new-post)
 *  Thread Starter [espacemusculation](https://wordpress.org/support/users/espacemusculation/)
 * (@espacemusculation)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/problem-with-defer/#post-10267576)
 * I found this in my function file :
 * //to add defer to loading of scripts – use defer to keep loading order
    function
   script_tag_defer($tag, $handle) { if (is_admin()){ return $tag; }
 *  if (strpos($_SERVER[‘HTTP_USER_AGENT’], ‘MSIE 9.’) !==false) {
    return $tag;}
   else { return str_replace(‘ src’,’ defer src’, $tag); } } add_filter(‘script_loader_tag’,‘
   script_tag_defer’,10,2); //to add defer to loading of scripts – use defer to 
   keep loading order
 * **Can you help me to add an exemption for amp file ??**
    -  This reply was modified 8 years, 5 months ago by [espacemusculation](https://wordpress.org/support/users/espacemusculation/).
 *  [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/problem-with-defer/#post-10268270)
 * **Conditional To Output defer**
 * Hi [@espacemusculation](https://wordpress.org/support/users/espacemusculation/),
   
   Here’s a way to not output the `defer` attribute on AMP endpoints.
 * In place of:
 *     ```
       else {
               return str_replace( ' src', ' defer src', $tag );
       }
       ```
   
 * use:
 *     ```
       elseif ( ! function_exists( 'is_amp_endpoint' ) || ! is_amp_endpoint() ) {
       	return str_replace( ' src', ' defer src', $tag );
       }
       return $tag;
       ```
   
    -  This reply was modified 8 years, 5 months ago by [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/).
 *  Thread Starter [espacemusculation](https://wordpress.org/support/users/espacemusculation/)
 * (@espacemusculation)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/problem-with-defer/#post-10268868)
 * THANKS YOU very much 😀
 *  [thiagomsouza](https://wordpress.org/support/users/thiagomsouza/)
 * (@thiagomsouza)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/problem-with-defer/#post-10412504)
 * I had the same problem,
 * I use the Speed Booster plugin, and there is a option:
 *  Defer parsing of javascript files
 * To resolve is just deselect this option, save and cleanup the cache.
 * []´s

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

 The topic ‘Problem with “defer”’ is closed to new replies.

 * ![](https://ps.w.org/amp/assets/icon.svg?rev=2527602)
 * [AMP](https://wordpress.org/plugins/amp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amp/)
 * [Active Topics](https://wordpress.org/support/plugin/amp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amp/reviews/)

## Tags

 * [ads](https://wordpress.org/support/topic-tag/ads/)
 * [defer](https://wordpress.org/support/topic-tag/defer/)
 * [script](https://wordpress.org/support/topic-tag/script/)

 * 6 replies
 * 5 participants
 * Last reply from: [thiagomsouza](https://wordpress.org/support/users/thiagomsouza/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/problem-with-defer/#post-10412504)
 * Status: resolved