Reputation: 95
Today I noticed the blog section of my site was not rendering correctly, and the console was spitting out errors that I knew where to do with jquery not loading.
When I looked at source code all the scripts that where added by WordPress (wp_enqueue_script) had an extra element added to it, so:
<script type='text/javascript' src='//code.jquery.com/jquery-2.2.0.min.js'></script>
become:
<script type='text/javascript' src='//code.jquery.com/jquery-2.2.0.min.js' defer '></script>
so 'defer' and a single quote mark is being added.
I need these scripts to load in the , when I register the scripts I do set load in the footer as false.
I'm not sure why/how 'defer' is being added? Or why a single quote mark is also added? I'm also not sure if deferring them is what breaks the page or this rouge single quote mark?
I do use 'Autoptimize' but I have turned it off and cleared out all caches.
The only hack around it, short term, is to hardcode the scripts into the header.php and these are not deferred.
Upvotes: 0
Views: 632
Reputation: 2002
Our client had almost the same exact issue which was caused by a very outdated (and lazily written) plugin called ESB URL Extension that failed to account for a closing apostrophe.
Since our customer had quite a few active plugins on a live site (without staging options) I didn't want to start disabling things to locate the error. Instead, I installed the String Locator plugin (a great tool which I often use) and searched the plugin directory for occurrences of "defer" and was eventually able to identify the culprit.
Upvotes: 0
Reputation: 5920
Probably a (badly developed) plugin, disable plugins one by one until the defer attribute goes away. If not it could also be a theme thing, briefly switch to a default WordPress core theme to double-check?
frank
Upvotes: 1