• Hello,
    I have a site where user messages (in a bar on top of screen) are saved into cookies and are removed by javascript. The problem is the plugin seems to kill it when Optimize JavaScript Code is selected. I discovered that there is a code snippet: <script>Cookies.remove(‘messages’);</script> in a php file that i need to function. How can i get the plugin to ignore this snippet? I cannot seem to determine the identifier as none have worked.. (per faqs) – How would i use a no-optimize tag for this?
    Thanks! BTW, the plugin works great! (aside from this minor theme issue.. :))

    Thanks a lot!

    • This topic was modified 7 years, 1 month ago by kappler0.
    • This topic was modified 7 years, 1 month ago by kappler0. Reason: detail update
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Frank Goossens

    (@futtta)

    depends; is that block of JS-code inlined in the output HTML? or is the php-file referenced?

    frank

    Thread Starter kappler0

    (@kappler0)

    You know i am really not sure… The entire file code is:

    <?php $messages = Inventor_Utilities::get_messages(); ?>
    <?php if ( ! empty( $messages ) && is_array( $messages ) ) : ?>
        <div class="alerts">
            <?php foreach ( $messages as $message ) : ?>
                <div class="alert-primary alert alert-dismissible alert-<?php echo esc_attr( $message[0] ); ?>">
                    <div class="alert-inner">
                        <div class="container">
                            <?php echo wp_kses( $message[1], wp_kses_allowed_html( 'post' ) ); ?>
    
                            <button type="button" class="close" data-dismiss="alert"><i class="fa fa-close"></i></button>
                        </div>
                    </div><!-- /.alert-inner -->
                </div><!-- /.alert -->
            <?php endforeach; ?>
        </div><!-- /.alerts -->
    
       <script>Cookies.remove('messages');</script>
    <?php endif; ?>

    This does not work btw: <!–noptimize–> <script>Cookies.remove(‘messages’);</script> <!–/noptimize–>

    • This reply was modified 7 years, 1 month ago by kappler0.
    Plugin Author Frank Goossens

    (@futtta)

    OK, can you share your URL so I can have a quick look?

    Thread Starter kappler0

    (@kappler0)

    https://equinerising.com

    (you will prob need to register to see it)

    thx!

    • This reply was modified 7 years, 1 month ago by kappler0.
    Plugin Author Frank Goossens

    (@futtta)

    well, don’t see that JS even with AO disabled (add ?ao_noptimize=1 to the URL) but that might be because I’m not logged in?

    but did you try adding plugins/inventor/ to the JS optimization exclusion list (as your PHP-snippet mentions Inventor_Utilities?

    frank

    Thread Starter kappler0

    (@kappler0)

    hi, so i tried adding the plugin /inventor but still no luck.

    i did see this with chrome inspector:
    Uncaught ReferenceError: Cookies is not defined
    at autoptimize_7b4b5bc….js:1998

    thx,
    Scott

    Plugin Author Frank Goossens

    (@futtta)

    well, it does confirm we’re getting closer 🙂

    there’s plugins/inventor/libraries/js.cookie.js which should already be excluded, but also plugins/inventor-google-map/libraries/js-cookie.js, so add plugins/inventor-google-map/ to the exclusions maybe?

    have a nice weekend!
    frank

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Plugin – cookies – inline js – issue’ is closed to new replies.