If $X$ Hausdorff, compact with $G_{\delta }$ diagonal then $X$ has a countable basis Suppose that $X$ is a Hausorff and compact space. Moreover, suppose that $\Delta:=\{(x,x):x\in X\}$ is a $G_{\delta}$ set. I need to show that $X$ has a countable basis.
As $X$ is Hausdorff, $\Delta$ is closed in $X\times X$, moreover, as $X\times X$ is compact and Hausdorff then it is a normal space. Now, as $\triangle$ is a $G_{\delta}$ closed set, there exists a continuous function $f:X\times X\to \mathbb{R}$ such that $f^{-1}(\{0\})=\Delta$ (It follows by Urysohn's lemma). Let $\mathcal{B}:=\{B_n\mid n\in\omega\}$ be a countable basis for $\mathbb{R}$ and consider the set $\{f^{-1}(B_n)\mid  n\in\omega\}$. I claim that this set is a basis for $X\times X$.
As $f$ is continuous with compact domain and Hausdorff image, $f$ is a closed function. Let $G\subseteq X\times X$ be an open set. So $\mathbb{R}\setminus f[(X\times X)\setminus G]$ is a open set in $\mathbb{R}$. Let $n\in\omega$ such that $B_n\subseteq \mathbb{R}\setminus f[(X\times X)\setminus G]$, so we have that $f^{-1}(B_n)\subseteq G$. Then $X\times X$ has a countable basis, so $X$ has a countable basis too.
I think that there is a mistake in my proof because I don't use the fact that $\Delta$ is $G_{\delta}$ in a significant way. Can someone tell me where I am wrong?    
 A: The inverse images of the $B_n$ won't necessarily form a countable base for $X \times X$. So you need a better approach:
You can show that if $\Delta$ is a $G_\delta$ in $X^2$ and $X$ is compact Hausdorff then $X$ has a countable $T_2$-separating family of open sets (proof below). (Such a family $\mathcal{O}$ has the property that for all $x \neq y$ in $X$ we have $O_1,O_2 \in \mathcal{O}$ with $x \in O_1, x \in O_2, O_1 \cap O_2=\emptyset$) and this implies that $X$ has countable weight, by compactness: the topology $\tau$ generated by $\mathcal{O}$ is second countable and Hausdorff and a subset of the original topology $\tau_X$ on $X$ so the identity $1_X: (X, \tau_X) \to (X,\tau)$ is a continuous closed (compact to Hausdorff) bijection and so $\tau_X=\tau$ and we're done; a standard argument. 
The family $\mathcal{O}$ can be found as follows: write $\Delta = \bigcap_n U_n$ where $U_n \subseteq X^2$ open. Fix $n$ and for each $x \in X$ find $O^n_x$ open in $X$ containing $x$ such that $O^n_x \times O^n_x \subseteq U_n$ by openness of $U_n$. Find an open $V^n_x$ containing $x$ such that $\overline{V^n_x} \subseteq O^n_x$ by regularity of $X$. Finitely many of these cover $X$ by compactness, so we have $F_n \subseteq X$ finite such that $X = \bigcup \{V^n_x: x \in F_n\}$. Now define 
$$\mathcal{O} = \{V^n_x, X\setminus \overline{V^n_x}\mid x \in F_n, n \in \Bbb N\}$$
and check that $\mathcal{O}$ is (countable and) $T_2$-separating. (And so these form a countable subbase for $X$ as we saw in the final argument of the first paragraph.)
A: Existence of $f$ requires the fact that $\Delta$ is  a $G_{\delta}$ set. If we arite $\Delta$ as the intersection of open sets $U_1,U_2,...$ then there exits $f_n$'s which are $0$ on $\Delta$ and $1$ on $U_n^{c}$ with $0\leq f_n \leq 1$ and $f =\sum \frac 1 {2^{n}} f_n$ would serve the purpose. 
