Title: Force JavaScript in is breaking mobile menu
Last modified: February 4, 2020

---

# Force JavaScript in is breaking mobile menu

 *  [andremedinaw](https://wordpress.org/support/users/andremedinaw/)
 * (@andremedinaw)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/)
 * If I enable on:
    **JavaScript Options**
    - Force JavaScript in <head>?
    - and also
    - Add try-catch wrapping?
    - it makes the site really fast but when you tap on menu (mobile) it wont open
      
      I already tryed CSS, JavaScript all options and all works perfect but the 
      only 2 options that makes a huge diference on speed but breaks the tap on 
      mobile is that. Can you please help me to find a way to fix it and keep that
      2 optins checked
    - Right now that options is not enable on my website, so mobile menu is working
      good at the moment.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fforce-javascript-in-is-breaking-mobile-menu%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/#post-12396577)
 * Given “force JS in head” makes the JS render-blocking (meaning it will result
   in the first display of your page being slower) and that [“add try/catch wrapping” will result in the JS executing slower](https://blog.futtta.be/2014/08/18/when-should-you-trycatch-javascript/),
   I would advice against those settings actually andremedinaw 🙂
 *  Thread Starter [andremedinaw](https://wordpress.org/support/users/andremedinaw/)
 * (@andremedinaw)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/#post-12396614)
 * ok, thanks for the reply, but when enable it, the speed goes from 66 to 96 on
   page speed insights, that is why I´ll love to make it enable 😀
    Is there any
   way to exclude the menu scripts
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/#post-12396628)
 * Aha, the (un)holy grail 😉
 * You could try adding `setup_collapsible_submenus` to the comma-separated JS optimization
   exclusion list maybe?
 *  Thread Starter [andremedinaw](https://wordpress.org/support/users/andremedinaw/)
 * (@andremedinaw)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/#post-12396660)
 * yea, just did but still not working
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/#post-12396728)
 * Any JS errors in the browser console?
 *  Thread Starter [andremedinaw](https://wordpress.org/support/users/andremedinaw/)
 * (@andremedinaw)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/#post-12396821)
 * yes,
    - Uncaught SyntaxError: Unexpected end of input: autoptimize_8b1bc32a50add0c7d3893823ded9f3fc.
      js:160
    - and
    - Uncaught ReferenceError: jQuery is not defined
       at (index):509
    - that 2 errors cames up
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/#post-12397102)
 * OK, first things first; you’ll have to (re-)exclude `js/jquery/jquery.js`.
 *  Thread Starter [andremedinaw](https://wordpress.org/support/users/andremedinaw/)
 * (@andremedinaw)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/#post-12397119)
 * ok, I have to add again to the comma-separated JS optimization exclusion list?
   
   becouse I already remove it
 *  Thread Starter [andremedinaw](https://wordpress.org/support/users/andremedinaw/)
 * (@andremedinaw)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/#post-12397159)
 * ok, done! excluded
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/#post-12397163)
 * OK, so what happens now (menu + JS errors)?
 *  Thread Starter [andremedinaw](https://wordpress.org/support/users/andremedinaw/)
 * (@andremedinaw)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/#post-12397202)
 * mobile menu open a little gap under the nav and the hamburguer dont open when
   tap on it.
 * error:
    Uncaught SyntaxError: Unexpected end of input: autoptimize_ff7595631a38a5ce23b6686754b22fe5.
   js:154
 * using this: setup_collapsible_submenus and js/jquery/jquery.js
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/#post-12397211)
 * and if you disable “try/catch wrapping”?
 *  Thread Starter [andremedinaw](https://wordpress.org/support/users/andremedinaw/)
 * (@andremedinaw)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/#post-12397262)
 * yeap, same…
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/#post-12398088)
 * In that case look at the JS file at/ around the x-th character as mentioned in
   the JS error and look for keywords to understand what JS-file the code originates
   from and then try to exclude that file from JS optimization.
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/#post-12442860)
 * any news [@andremedinaw](https://wordpress.org/support/users/andremedinaw/) ?

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

The topic ‘Force JavaScript in is breaking mobile menu’ is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 15 replies
 * 2 participants
 * Last reply from: [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * Last activity: [6 years, 3 months ago](https://wordpress.org/support/topic/force-javascript-in-is-breaking-mobile-menu/#post-12442860)
 * Status: not resolved