Disqus error
-
I have both the Disqus comments plugin and Autoptimize installed. When I have Autoptimize enabled for JavaScript, Disqus fails.
Disqus appears to add these scripts at the bottom of the page:
<script type='text/javascript'>/* */ var embedVars = {"disqusConfig":{"platform":"wordpress@4.3.1","language":""},"disqusIdentifier":"3415 http:\/\/beaconathletics.com\/ballfields\/?p=3415","disqusShortname":"beaconathletics","disqusTitle":"NRPA 2015","disqusUrl":"http:\/\/ballfields.com\/2015\/10\/01\/nrpa-2015\/","options":{"manualSync":false},"postId":"3415"}; /* */</script> <script type='text/javascript' src='http://ballfields.com/wp-content/plugins/disqus-comment-system/media/js/disqus.js?ver=4.3.1'></script> <script type='text/javascript'>/* */ var countVars = {"disqusShortname":"beaconathletics"}; /* */</script> <script type='text/javascript' src='http://ballfields.com/wp-content/plugins/disqus-comment-system/media/js/count.js?ver=4.3.1'></script>
When Autoptimize is enabled for JS, I only see the following:
<script type='text/javascript' src='http://ballfields.com/wp-content/plugins/disqus-comment-system/media/js/disqus.js?ver=4.3.1'></script>
And I get the following error in the console:
Uncaught ReferenceError: embedVars is not defined
It sounds to me like the problem is due to the in-line script that sets embedVars getting concatenated into the main scripts file. Unfortunately, since it’s in-line there is no filename to add to the exclusions list. Is there any way to prevent this script from being concatenated?
Limiting Autoptimize to scripts in head, as I’ve seen suggested in response to similar questions, isn’t really a realistic workaround for me. In keeping with generally accepted best practices, nearly all of my scripts are referenced at the end of the body, so limiting Autoptimize to the head is not much better than disabling it entirely.
If there’s not currently a solution for this, is it possible an option to exclude all in-line scripts could be added? I realize targeting specific ones would be extremely difficult, but it seems like only optimizing scripts loading from file, and ignoring in-line ones, should be relatively easy to implement.
- The topic ‘Disqus error’ is closed to new replies.