As mentioned above, I use discourse as the commenting system and here’s an example
Quite a few users upload images to the comments and the JS itself is impacting the load time.
Is there a way I can load the commenting system only on scroll? Which if you think about it makes sense – you need to load it only on user intent – when to read comments.
Edit
This is the code I use
<div id="comments" class="ct-post-end-section">
<div id='discourse-comments'></div>
<script type="text/javascript">
DiscourseEmbed = { discourseUrl: 'https://comments.alittlebitofspice.com/',
discourseEmbedUrl: '<?php echo get_permalink(); ?>' };
(function() {
var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
})();
</script>
</div><!-- #comments -->
Wonder if it’s the right approach to attach the script to onscroll? Although I understand complexities between repeated scroll events firing.