Title: inline anonymous fn
Last modified: December 16, 2017

---

# inline anonymous fn

 *  Resolved [funsail](https://wordpress.org/support/users/funsail/)
 * (@funsail)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/inline-anonymous-fn/)
 * How can I exclude js like this
 *     ```
       (function()
       function addEventListener(element,event,handler)
       if(element.addEventListener)
       element.addEventListener(event,handler,false)
       ```
   
 * or
 *     ```
       else if(element.attachEvent)
       element.attachEvent('on'+event,handler)
       ```
   
 * or
 *     ```
       jQuery(function($)
       $(document).ready(function()
       if(/MSIE 10/i.test(navigator.userAgent)||/MSIE 9/i.test(navigator.userAgent)||/rv:11.0/i.test(navigator.userAgent)||/Edge\/\d./i.test(navigator.userAgent))
       $('.kameleon-cf7-container').each(function()
       var elem=$(this)
       var thestyle=elem.attr('data-style-css')
       var classname=elem.attr('data-classname')
       var styleType=elem.attr('data-style')
       var resultStyle=''
       var thestyle=thestyle.split("
       ")
       resultStyle+=classname+' .km_cf7-submit-container
       text-align: '+kswr_get_splitted_value(thestyle,"--kmcf7-btn-align")+'
       ```
   

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

 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/inline-anonymous-fn/#post-9788211)
 * the first two blocks are too generic really (although you could exclude `addEventListener`
   or `attachEvent`, but that could lead to more being excluded).
 * but for the 3rd block I would use `.kameleon-cf7-container` or `kswr_get_splitted_value`
   for example.
 * hope this helps,
    frank
 *  Thread Starter [funsail](https://wordpress.org/support/users/funsail/)
 * (@funsail)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/inline-anonymous-fn/#post-9789439)
 * I think the top 2 came from Also aggregate inline JS
    also the 3rd too.
 * How can we take advantage of Also aggregate inline JS? So many plugins litter
   like this.
 *  Thread Starter [funsail](https://wordpress.org/support/users/funsail/)
 * (@funsail)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/inline-anonymous-fn/#post-9789464)
 * How do you do
 *     ```
        @media(max-width:460px){.snp-powered-b{display: none;}}
       ```
   
 * just ‘.snp-‘ doesn’t work
    kswr_get_splitted_value doesn’t seem to work for above
   either.
 * Almost want to separate [all inline css] into a different file with diff Exclude
   options line.
    -  This reply was modified 8 years, 5 months ago by [funsail](https://wordpress.org/support/users/funsail/).
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/inline-anonymous-fn/#post-9789531)
 * > I think the top 2 came from Also aggregate inline JS
 * not sure what you mean by that; “also aggregate inline JS” will not introduce
   new JS in the HTML, it will try to remove all inline JS from the HTML except 
   the blocks that contain blacklisted strings (e.g. `nonce`, `document.write`, `
   GoogleAnalyticsObject`).
 * > just ‘.snp-‘ doesn’t work
   >  kswr_get_splitted_value doesn’t seem to work for
   > above either.
 * well, try `snp-powered-b`. no idea why `kswr_get_splitted_value` would not work
   I’m afraid, it really should do the trick.
 *  Thread Starter [funsail](https://wordpress.org/support/users/funsail/)
 * (@funsail)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/inline-anonymous-fn/#post-9789574)
 * I mean that inline JS is fundamentally different from normal JS. It’s full of
   stuff that is Anonymous or otherwise cannot be excluded for whatever reason..
   I’d like to work out some way it can work, and is it better for the inline to
   be left in and having 1 aggregated file, or aggregating that but ending up with
   5 files. For example the gtmetrix site thinks that it’s better if the inline 
   stuff is aggregated and put away in 1 spot.
 * snp-powered-b and other combinations also do not work. Again it seems to be something
   to do with inline
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/inline-anonymous-fn/#post-9789702)
 * > snp-powered-b and other combinations also do not work. Again it seems to be
   > something to do with inline
 * don’t understand … to be clear, excluding based on words in the code can _only_
   be done for inline JS/ CSS. if you have JS/ CSS in files, you have to exclude
   using a word from the path and/ or filename.
 *  Thread Starter [funsail](https://wordpress.org/support/users/funsail/)
 * (@funsail)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/inline-anonymous-fn/#post-9795122)
 * OK just to be clear
 * 1. if you have JS/ CSS in files, and I put a variable from a file, it won’t exclude
   the file
 * 2. for inline JS/ CSS, is it a single word or any matching text between the ‘,’
   
   eg xxx,”use strict”;function c(),xxx
 *  Thread Starter [funsail](https://wordpress.org/support/users/funsail/)
 * (@funsail)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/inline-anonymous-fn/#post-9795127)
 * but if I put in vc_custom_ how does it know if it’s a string or filename?
 *  Plugin Author [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * (@optimizingmatters)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/inline-anonymous-fn/#post-9795183)
 * Correct; for inline JS you use a keyword from the code, linked files are excluded
   based on path.
 * While doing aggregation of linked files, AO matches all exclusions with the path
   of the file. While aggregating inline JS, it matches all exclusions with the 
   inline code. so if you would have a file `/wp-content/plugins/visualcomposer/
   vs_custom_how.js` and you would have inline JS with `vc_custom_how = "visual 
   composor how to";` then both would match and the file and the inline JS would
   be excluded.
 * frank

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

The topic ‘inline anonymous fn’ 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/)

 * 9 replies
 * 2 participants
 * Last reply from: [Optimizing Matters](https://wordpress.org/support/users/optimizingmatters/)
 * Last activity: [8 years, 4 months ago](https://wordpress.org/support/topic/inline-anonymous-fn/#post-9795183)
 * Status: resolved