From Insert code into the page context using a content script
var s = document.createElement('script');
// TODO: add "script.js" to web_accessible_resources in manifest.json
s.src = chrome.extension.getURL('script.js');
s.onload = function() {
this.parentNode.removeChild(this);
};
(document.head||document.documentElement).appendChild(s);
I've read all the topics on Stack..., and documentation from Google concerning Google Chrome Extensions and script injection but I don't understand the purpose of line 5 in the above injection script code:
this.parentNode.removeChild(this);
I may need some JavaScript learning, I know, but what happens if you don't remove the script after it is executed? Will the extension crash? Is it just for clean coding or does it have a certain purpose?