Defer jQuery works too good
-
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 schema.org 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": "http://schema.org", "@type": "AutoRental"} </script> <?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 gegevensOnjuist waardetype
Eén instantie
Regel 881:84
vand on this line in the page source I see this:
gtag('config', '******');</script> <script type="application/ld+json">var aoDeferInlineJQuery=function(){{ "@context": "http://schema.org", "@type": "AutoRental" etc etcThis 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]
The topic ‘Defer jQuery works too good’ is closed to new replies.