SEO Snippet & Content Analyzer
Characters: 0 / 60 (Recommended)
Characters: 0 / 160 (Recommended)
Analysis Results
Top Keywords Density (Non-Stopwords)
function runSEOAnalysis() {
var titleText = document.getElementById('seo-title-input').value;
var descText = document.getElementById('seo-desc-input').value;
var bodyText = document.getElementById('seo-body-input').value;
if (!bodyText && !titleText) {
alert('Please enter some content to analyze.');
return;
}
// Character counts for snippets
var titleLen = titleText.length;
var descLen = descText.length;
document.getElementById('title-count-msg').innerText = 'Characters: ' + titleLen + ' / 60 ' + (titleLen > 60 ? '(Too Long)' : '(Good)');
document.getElementById('title-count-msg').style.color = (titleLen > 60 || titleLen 160 ? '(Too Long)' : '(Good)');
document.getElementById('desc-count-msg').style.color = (descLen > 160 || descLen 2; });
var totalWordCount = words.length;
// Basic stopwords list
var stopWords = ['the', 'and', 'for', 'with', 'this', 'that', 'from', 'are', 'was', 'were', 'has', 'have', 'but', 'not', 'your', 'can', 'all', 'more', 'about'];
var freqMap = {};
for (var i = 0; i < words.length; i++) {
if (stopWords.indexOf(words[i]) === -1) {
freqMap[words[i]] = (freqMap[words[i]] || 0) + 1;
}
}
var sortedKeywords = Object.keys(freqMap).sort(function(a, b) {
return freqMap[b] – freqMap[a];
});
// Display
document.getElementById('seo-results-panel').style.display = 'block';
document.getElementById('res-word-count').innerText = totalWordCount;
document.getElementById('res-read-time').innerText = Math.ceil(totalWordCount / 225) + ' min';
var tableHtml = '
';
tableHtml += '| Keyword | Frequency | Density |
';
var limit = Math.min(sortedKeywords.length, 8);
for (var j = 0; j < limit; j++) {
var kw = sortedKeywords[j];
var count = freqMap[kw];
var density = ((count / totalWordCount) * 100).toFixed(1);
tableHtml += '';
tableHtml += '| ' + kw + ' | ';
tableHtml += '' + count + ' | ';
tableHtml += '' + density + '% | ';
tableHtml += '
';
}
tableHtml += '
';
document.getElementById('density-output').innerHTML = tableHtml;
}
function resetSEOFields() {
document.getElementById('seo-title-input').value = ";
document.getElementById('seo-desc-input').value = ";
document.getElementById('seo-body-input').value = ";
document.getElementById('seo-results-panel').style.display = 'none';
document.getElementById('title-count-msg').innerText = 'Characters: 0 / 60 (Recommended)';
document.getElementById('desc-count-msg').innerText = 'Characters: 0 / 160 (Recommended)';
document.getElementById('title-count-msg').style.color = '#666';
document.getElementById('desc-count-msg').style.color = '#666';
}