I think I have found a possible memory leak / performance bug while doing some scripting.
I needed to put some extra tags in the head of the html so I created this script.
// Create array of head tags to be added
var headTags = [
'<!-- The character set should be utf-8 -->',
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">',
'<!-- Enables media queries -->',
'<meta name="viewport" content="width=device-width">'
];
// Add the head tags to the head
results.html(results.html() + headTags.join(' '));
After using this for some time my program became slower and slower. Then I looked at the generated HTML and saw thousands of extra head tags. This script kept adding them and saving them, not reloading the default head code it seems.
I have created a workaround for this issue but I would like to see a better solution.
// Create array of head tags to be added
var headTags = [
'<!-- The character set should be utf-8 -->',
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">',
'<!-- Enables media queries -->',
'<meta name="viewport" content="width=device-width">'
];
// Create regex to remove duplicate head tags as workaround
// For some reason if you add tags to the head they stay there forever. So when you reload the page it gets added again and again and again.
var regexFixHead = new RegExp('(' + headTags.join(' ').replace('/', '\/') + '){1,}', 'gi');
// Use workaround regex on head
results.html(results.html().replace(regexFixHead, ''));
// Add the head tags to the head
results.html(results.html() + headTags.join(' '));