Reputation: 2469
I'm writing some application and I needed to add the Facebook pagination to it.
I have read the post Jeff Bowen How-To: Paging with the Graph API and FQL, and it is great documentation. I used that and everything is working fine. But, everytime when I make request to Facebook to load new data, it creates a new 'script' element and load data inside it. If I do many requests, obviously after some time the page will be overloaded by these script tags. So, maybe there are another way to load data in the Facebook JavaScript SDK or.. Maybe I can delete the previous script tag after receiving a new one? And if I can - how I can do this?
Or.. is it OK to overload page this way? I had never done so.
PS: that piece of code from the documentation which creates tags:
function loadPosts() {
var script = document.createElement("script");
script.src = graphURL;
document.body.appendChild(script);
}
Upvotes: 0
Views: 625
Reputation: 4150
Refer to XML DOM - Remove Nodes.
Append the scripts into a div tag maybe below the body tag and clear it on each call.
<div id="scripts"></div>
<script>
function loadPosts() {
var script = document.createElement("script");
script.src = graphURL;
document.getElementById("sripts").innerHTML=""; // Clear all code from div tag
scriptthis=document.getElementById("scripts");
scriptthis.appendChild(script); // New script tag becomes 0
}
</script>
Upvotes: 3