• Resolved Nova

    (@big-dreams-theory)


    Hi

    I have a must use plugin for displaying tinymce in comments. This single file plugin contains the php code and a little piece of javascript, the problem is autoptimize disable my plugin when “optimize javascript cod” is enabled. I tried all the options in this panel with no better luck so i thought i could exclude this piece of javascript but it seems i can only exclude a javascript file (and it’s within the php). Hope you can help me. Thank you

    Javascript code is :

    <script type="text/javascript">
      jQuery(function($){
        $('.comment-reply-link').click(function(e){
          e.preventDefault();
          var args = $(this).data('onclick');
          args = args.replace(/.*\(|\)/gi, '').replace(/\"|\s+/g, '');
          args = args.split(',');
          tinymce.EditorManager.execCommand('mceRemoveEditor', true, 'comment');
          addComment.moveForm.apply( addComment, args );
          tinymce.EditorManager.execCommand('mceAddEditor', true, 'comment');
        });
      });
    </script>
    • This topic was modified 7 years, 8 months ago by Nova.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    As per the FAQ you can also exclude inline JS;

    if you want to exclude inline code, you’ll have to find a specific, unique string in that block of code and add that to the exclusion list. Example: to exclude <script>funky_data=’Won\’t you take me to, Funky Town'</script>, the identifier is “funky_data”.

    In your case I would try with tinymce.EditorManager.execCommand

    hope this helps,
    frank

    Thread Starter Nova

    (@big-dreams-theory)

    Thanks. I tried that but it didn’t work. And there’s not lot of options to try from this script

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    I tried that but it didn’t work

    Do you mean the inline JS is NOT excluded from optimization or that despite excluding you still have the JS error?

    What JS errors do you see on your browser console?

    Thread Starter Nova

    (@big-dreams-theory)

    Actually i forgot to check if i had errors previously. Oops
    The browser console report the same error with or without the exclusion :

    Uncaught ReferenceError: tinymce is not defined
        at (index):39
    
    JQMIGRATE: Migrate is installed, version 1.4.1 
    https://127.0.0.1/***********.com/wp-content/cache/autoptimize/js/autoptimize_dd5067165fdbaa5a39c5abc239ce123f.js

    If index 39 = line 39 of the plugin it’s <script type="text/javascript"> (well the begining of the script

    When js optimlization is disabled error is gone.
    Hope it helps

    • This reply was modified 7 years, 8 months ago by Nova.
    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Uncaught ReferenceError: tinymce is not defined
    at (index):39

    well, in that case look at the page without AO active (simply add ?ao_noptimize=1 to the URL) and in the HTML source look at JS the is related to tinymce and try excluding that? ??

    frank

    Thread Starter Nova

    (@big-dreams-theory)

    After looking at you just advise me to, I excluded tinymce.min.js and that did the trick
    Thank for the fast and efficient support ??

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    you’re welcome @big-dreams-theory, thank you for the great review! ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Optimize javascript code disable my must use plugin’ is closed to new replies.