Support » Plugin: Autoptimize » Defer jQuery works too good

  • Resolved jeroenm77


    Hey Frank,

    I’ve been using autoptimize for some time now and more recently added this code in a snippet autoptimize_defer_inline_jquery.php to defer all jQuery. Works like a charm!

    However, today I started adding a snippet to add some data to my site. I added this to the snippets (abbreviated for reading purpose):

    add_action( 'wp_footer', function () { ?>
    	<script type="application/ld+json"> {
              "@context": "",
              "@type": "AutoRental"}
    <?php } );

    The code seems valid and without the defer snippet active it works. When I active the defer snippet it apparantly wants to defer this script although it isnt jQuery. This gives a problem with the Google structured data tester. It gives an error:
    Fouten bij het parseren van gestructureerde gegevens

    Onjuist waardetype
    EÊn instantie
    Regel 881:84

    and on this line in the page source I see this:

    gtag('config', '******');</script> <script type="application/ld+json">var aoDeferInlineJQuery=function(){{
              "@context": "",
              "@type": "AutoRental"

    This leads me to think that the defer script isnt selecting jquery scripts only.

    Any ideas on this?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.