# Usando o Discourse como sistema de comentários via JavaScript: carregar com atraso ou carregar ao rolar

**URL:** <https://meta.discourse.org/t/using-discourse-as-commenting-system-via-javascript-delay-load-or-load-on-scroll/103724>\
**Category:** Product Support\
**Created:** [7 Dezembro , 2018 18:46 UTC](https://meta.discourse.org/t/using-discourse-as-commenting-system-via-javascript-delay-load-or-load-on-scroll/103724 "2018-12-07T18:46:25Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Jane\_Jojo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jane_jojo/32/119485_2.png) [@Jane\_Jojo](https://meta.discourse.org/u/Jane_Jojo)\
**Post date:** [7 Dezembro , 2018 18:46 UTC](https://meta.discourse.org/t/using-discourse-as-commenting-system-via-javascript-delay-load-or-load-on-scroll/103724/1 "2018-12-07T18:46:25Z")

</div>

As mentioned above, I use discourse as the [commenting system](https://meta.discourse.org/t/embedding-discourse-comments-via-javascript/31963?source_topic_id=74803) and here’s an example

> **[Soya Chunks Masala Dry](https://alittlebitofspice.com/soya-chunks-masala-dry-recipe)**
>
> Learn how to make Soya Chunks Masala Dry, a healthy stir-fry with soya chunks cooked in spices and chilies. A flavorful side dish .

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.

---

_[View the full topic](https://meta.discourse.org/t/using-discourse-as-commenting-system-via-javascript-delay-load-or-load-on-scroll/103724)._
