 				renderDependencyCountsGraph data
 		)
 	
+	lastQ = null
+	
 	searchField.keyup ->
 		
-		clearTimeout searchTimeoutId
-		
 		q = searchField.val()
 		
-		if q.length is 0
-			
-			renderDependencyCountsGraph(dependencyCounts)
-			
-		else if q.length > 2
-			
-			searchTimeoutId = setTimeout(
-				-> search q
-				1000
-			)
-	
-	if searchField.val()
-		renderDependencyCountsGraph {}
-		search searchField.val() +		if q isnt lastQ
+			
+			clearTimeout searchTimeoutId
+			
+			if q.length is 0
+				
+				renderDependencyCountsGraph(dependencyCounts)
+				
+			else if q.length > 2
+				
+				searchTimeoutId = setTimeout(
+					-> search q
+					1000
+				)
+			
+			lastQ = q
+	
+	# Get the dependency counts
+	d3.json 'dependency-counts.json', (error, data) ->
+		dependencyCounts = data
+		
+		if searchField.val()
+			search searchField.val() 
+		else
+			renderDependencyCountsGraph data
########################################################################################################################

$('#home-page').each ->
	
	url = $ '.badge-maker span'
	badge = $ '.badge-maker img'


$('#search-page').each ->
	
	dependencyCounts = {}
	
	searchForm = $ 'form'
	
	searchForm.submit (event) -> event.preventDefault()
	
	searchField = $ 'input', searchForm
	
