Title: Two things: Exclude CSS files and Inline javascripts
Last modified: August 21, 2016

---

# Two things: Exclude CSS files and Inline javascripts

 *  [akis](https://wordpress.org/support/users/akis/)
 * (@akis)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/)
 * There’s any chance to do any of those?
 * Why exclude CSS you may ask. Well, some plugins include the css files only on
   single or homepage for example, this will generate 2 separate and quite large(
   in some cases) combined&minified files which is pretty bad.
 * Thanks.
 * PS. Awesome plugin by the way, I was using BWP minify before.
 * [http://wordpress.org/plugins/autoptimize/](http://wordpress.org/plugins/autoptimize/)

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

1 [2](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/page/2/?output_format=md)

 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/#post-4026823)
 * well, 1.6.6 (eta 2nd half of september) should come with support for “do not 
   autoptimize” comment tags, like this;
    `<!-- noptimize --><script>alert("your
   javascript here</script><!-- /noptimize -->`
 * this should allow you to exclude whatever CSS & JS you want?
 *  Thread Starter [akis](https://wordpress.org/support/users/akis/)
 * (@akis)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/#post-4026838)
 * Thank you for your reply.
    This will be better but most of the inline javascript
   or css files are added automatically by plugins so not really helpful.
 * The exclusion of inline javascripts seems to work pretty well now, I didn’t realized
   at first. Excluding CSS by using the same method will be fine or by registered
   handle as BWP Minify does.
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/#post-4026962)
 * I’ll add CSS-exclusion (much like it works for JS) in version 1.7.0 (eta somewhere
   in Q4). Removing CDN & YUI from admin will give me some space for the CSS exclusion
   input field.
 *  [admintiger](https://wordpress.org/support/users/admintiger/)
 * (@admintiger)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/#post-4027025)
 * The “do not autoptimize” comment tags will be a valuable improvement, because
   they will make it possible to greatly reduce the number of cached files where
   inline js or css code changes from page-to-page. For example, I have a site that
   has about 5,000 content pages. Each of those pages has a single line of inline
   js code that is different from page-to-page, resulting in the creation of about
   5,000 unique js files in the cache. Masking that single line with <!– noptimize–
   > … <!– /noptimize –> tags will make it possible for all those content pages 
   to share a single js file. Not only will that greatly reduce the number of files
   cached on the server, but also will reduce visitor webpage loading times after
   any first page has been loaded.
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/#post-4027035)
 * I’m pushing a “beta”-version of 1.6.6 out ([download here](http://downloads.wordpress.org/plugin/autoptimize.zip)),
   which has noptimize-support.
 * A simple example of JS being excluded;
    `<!--noptimize--><script>alert('this 
   will not get autoptimized');</script><!--/noptimize-->`
 * Looking forward to your feedback!
 *  [admintiger](https://wordpress.org/support/users/admintiger/)
 * (@admintiger)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/#post-4027036)
 * Great! I will give it a try tomorrow afternoon.
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/#post-4027045)
 * Did you have the chance to test this admintiger?
 * fyi: up until this morning the 1.6.6 beta-version contained a bug where multiple
   noptimize-blocks were considered as one big block, but that was solved with a
   new commit in trunk.
 * Looking forward to your feedback! 🙂
 *  [Rajasekharan N](https://wordpress.org/support/users/nrajasekharan/)
 * (@nrajasekharan)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/#post-4027053)
 * I have a good news for you Futtta. Autoptimize 1.6.6. along with WP-Minify gives
   me a Google page speed score of 100/100.
 * However, I want to exclude an inline javascript whenever it is called. I am unable
   to use <!–noptimize–><!–/noptimize–> on the Autoptimize settings page. Am I doing
   something wrong?
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/#post-4027054)
 * Great Rajasekharan! the <!–noptimize–><!–/noptimize–>-code is supposed to be 
   in the raw HTML, not in the admin-screen (where exclusion is based on -part of-
   a filename).
 *  [Rajasekharan N](https://wordpress.org/support/users/nrajasekharan/)
 * (@nrajasekharan)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/#post-4027055)
 * Since it is an inline javascript, do you mean to add <!–noptimize–> in the raw
   php file where the javascript code appears, altering the template? But that would
   be erased every time the template is updated?
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/#post-4027056)
 * True (although in general themes don’t tend to get updated often?). In that case
   you can also add a string (e.g. “window.location.replace” in your case) from 
   the inline javascript to the “Exclude scripts from autoptimize”-list in the admin-
   screen.
 *  [Rajasekharan N](https://wordpress.org/support/users/nrajasekharan/)
 * (@nrajasekharan)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/#post-4027057)
 * Wow. Thanks for the lightning speed reply. As we talked about a theme update 
   here, there came one update, Graphene 1.9.1 to 1.9.2.
 * After updating the theme, I tried both the methods that you said above. However,
   it is not working. The script is an automated search on a 404 page. If I disable
   minifying/optimizing javascript, it works smoothly; if I enable it, automated
   search is not working. This holds good for both WP-Minify and Autoptimize.
 * Initially I came here searching for an option to exclude inline javascript and
   tried Autoptimize. The primary intention didn’t work; however, page speed score
   moved a notch up from 99 to 100! I would be glad if I could exclude that inline
   javascript too.
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/#post-4027058)
 * well exclusions can be tricky, requiring trial and error. sometimes “look for
   scripts only in head” is the easier solution, maybe you could try that?
 *  [Rajasekharan N](https://wordpress.org/support/users/nrajasekharan/)
 * (@nrajasekharan)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/#post-4027059)
 * When I tick the option “Force JavaScript in <head>?” the autosearch on 404 works,
   irrespective of whether I tick or not “Look for scripts only in <head>?” However,
   the page speed score dropped to 96/100.
 * So I think now I may have to forgo either the full page speed score or the autosearch
   on a 404. However, I would love to have them both.
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/#post-4027060)
 * I did [a quick test with graphene on my testblog](http://futtta.be/wordpress/lyte)(
   good thing graphene isn’t a “premium” plugin) and got it working.
 * Excluding “window.location.replace” works, but the entire snippet of javascript
   that is excluded that way, requires jquery to be loaded. So if you configure 
   autoptimize to exclude
 *     ```
       window.location.replace, jquery.js
       ```
   
 * from javascript optimization, then it indeed does work. But you’ll probably not
   have an incredible 100 pagespeed score any more.
 * I would be interested in seeing your pagespeed score for wp-minify standalone,
   autoptimize standalone and the two combined by the way, would you be willing 
   to test and share that? 🙂

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

1 [2](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/page/2/?output_format=md)

The topic ‘Two things: Exclude CSS files and Inline javascripts’ 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/)

 * 22 replies
 * 4 participants
 * Last reply from: [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/two-things-exclude-css-files-and-inline-javascripts/page/2/#post-4027078)
 * Status: not a support question