SEO – onload components seen as separate pages by Google


I have tried to optimized my blog by loading some component after the page load to improve the performance. Since I have done this, the performance has increased but I now see that those components have been indexed in Google search.

I have use the following code to load my components

window.onload = function (e)  {   loadComments();   loadFeeds(); } 

and then one of the functions:

function loadComments() {     event.preventDefault();     console.log('Loading comments');     fetch('https://www.laurentwillen.be/gadgets/xiaomi-mi-10-lite-5g-test-avis/?module=comments&r=".rand(0,1500); ?>',          {             method: 'GET',             headers : new Headers()         })     .then(response => response.text())     .then((response) =>          {             document.getElementById('comments-content').innerHTML=response;             // PREFEED COMMENT FORM             reply_links = document.querySelectorAll(".feed_form");             for (x=0;x<reply_links.length;x++)                 {                     local_reply = reply_links[x];                     local_reply.addEventListener("click", feedComment);                                      }          })     .catch((err)=>console.log(err))  } 

I can see that the url https://www.laurentwillen.be/gadgets/xiaomi-mi-10-lite-5g-test-avis/?module=comments is now indexed in Google and that’s not what I want.

Should I load the page differently? Or should I add something to the loaded component?

Thanks