Title: Exclude javascript from optimization
Last modified: November 15, 2023

---

# Exclude javascript from optimization

 *  Resolved [impex23](https://wordpress.org/support/users/impex23/)
 * (@impex23)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/exclude-javascript-from-optimization/)
 * Hi, I have an issue with autoptimize plugin in one of my websites , as we have
   done the settings and checked the Optimize JavaScript Code? non-logged-in users
   are not able to view the js scripts. The website is done using Timber Framework
   with WordPress and also is there any option to exclude the twig file in which
   we have all scripts called scripts.twig but this is not an external js file, 
   the code written here are visible in the view page source and there is no scripts.
   twig in the source code
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fexclude-javascript-from-optimization%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/exclude-javascript-from-optimization/#post-17203135)
 * when “optimize JavaScript” is on, what errors do you see on the browser console?
 * re. twig JS; if that is inline simply deactivate the option to aggregate (or 
   defer) the inline JS?
 *  Thread Starter [impex23](https://wordpress.org/support/users/impex23/)
 * (@impex23)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/exclude-javascript-from-optimization/#post-17203375)
 * I am not getting any error in the console but the js code is not visible in the
   view page source for non-logged in users, how to fix this issue and this is dropping
   the core web vitals, so I need to keep js code visible and also to fix core web
   vitals
 *  Thread Starter [impex23](https://wordpress.org/support/users/impex23/)
 * (@impex23)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/exclude-javascript-from-optimization/#post-17203428)
 * Also aggregate inline JS?
   when I check this option I am getting that issue, as
   the non-logged in users are not able to view the js code in the view source code,
   how to fix it
    -  This reply was modified 2 years, 6 months ago by [impex23](https://wordpress.org/support/users/impex23/).
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/exclude-javascript-from-optimization/#post-17203482)
 * well, JS code does not have to visible, the reason it’s not visible is that it’s
   part of the aggregated file. but if you don’t want that you can keep that option
   disabled?
 *  Thread Starter [impex23](https://wordpress.org/support/users/impex23/)
 * (@impex23)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/exclude-javascript-from-optimization/#post-17203540)
 * if that option is disabled, then core web vitals will be more than 9.5 s
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/exclude-javascript-from-optimization/#post-17203569)
 * well, as JS code does not have to be visible in the HTML to function, you could
   simply let the inline JS be aggregated?
 * OR you could exclude specific inline JS by adding a (unique) keyword that is 
   in the block of inline JS you would like to keep in the HTML?
 *  Thread Starter [impex23](https://wordpress.org/support/users/impex23/)
 * (@impex23)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/exclude-javascript-from-optimization/#post-17203577)
 * desktop will be fixed, I am talking about mobile core web vitals
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/exclude-javascript-from-optimization/#post-17203596)
 * I had a quick look at the Pagespeed Insights for mobile; the biggest issue by
   far currently is the “server response time”, for which you should implement page
   caching (this is not part of Autoptimize, but you can install e.g. KeyCDN Cache
   Enabler for that or you could give Autoptimize Pro a try).
 * Javascript-wise the biggest issue seems to be with the Google Tag Manager code
   which AO can’t optimize. consider simplifying the amount of logic implemented
   in GTM?
 *  Thread Starter [impex23](https://wordpress.org/support/users/impex23/)
 * (@impex23)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/exclude-javascript-from-optimization/#post-17203716)
 * Okay, thanks for the quick response so issue is not from Autoptimize then, we
   will try to check with server response time then, thank you
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/exclude-javascript-from-optimization/#post-17203718)
 * you’re welcome, feel free to [leave a review of the plugin and support here](https://wordpress.org/support/plugin/autoptimize/reviews/#new-post)!
   🙂
 * frank

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

The topic ‘Exclude javascript from optimization’ 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/)

 * 10 replies
 * 2 participants
 * Last reply from: [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * Last activity: [2 years, 6 months ago](https://wordpress.org/support/topic/exclude-javascript-from-optimization/#post-17203718)
 * Status: resolved