SEO Content Health Checker
Real-time analysis for search engine optimization
function runSeoAnalysis() {
var content = document.getElementById('seoContentInput').value;
var keyword = document.getElementById('seoKeywordInput').value.toLowerCase().trim();
var resultsPanel = document.getElementById('seoResultsPanel');
var resList = document.getElementById('resList');
if (!content) {
alert('Please enter content to analyze.');
return;
}
resultsPanel.style.display = 'block';
resList.innerHTML = ";
var words = content.trim().split(/\s+/).filter(function(w) { return w.length > 0; });
var wordCount = words.length;
document.getElementById('resWordCount').innerText = wordCount;
var keywordCount = 0;
if (keyword) {
var cleanContent = content.toLowerCase().replace(/[^\w\s]/gi, ' ');
var regex = new RegExp('\\b' + keyword + '\\b', 'g');
var matches = cleanContent.match(regex);
keywordCount = matches ? matches.length : 0;
var density = ((keywordCount / wordCount) * 100).toFixed(2);
document.getElementById('resDensity').innerText = density + '%';
} else {
document.getElementById('resDensity').innerText = 'N/A';
}
var findings = [];
if (wordCount < 300) {
findings.push(['🔴', 'Content length is too short. Aim for at least 600 words for better ranking.']);
} else if (wordCount 2.5) {
findings.push(['🔴', 'Keyword stuffing detected (' + densityVal.toFixed(2) + '%). Reduce keyword usage.']);
} else if (densityVal >= 0.5 && densityVal 25) {
findings.push(['🟡', 'Sentences are quite long. Consider breaking them up for readability.']);
} else {
findings.push(['🟢', 'Sentence flow is good for user engagement.']);
}
for (var i = 0; i < findings.length; i++) {
var li = document.createElement('li');
li.style.padding = '10px';
li.style.marginBottom = '8px';
li.style.background = '#f8fafc';
li.style.borderRadius = '6px';
li.style.fontSize = '14px';
li.style.display = 'flex';
li.style.alignItems = 'center';
li.innerHTML = '
' + findings[i][0] + ' ' + findings[i][1] + '';
resList.appendChild(li);
}
}