I don’t want to just jump in, be an ass, and necro a thread when you’ve already got your solution, but it would be nice to expand on why its your solution.
As much as the proposed solutions resolves your solution, those using the same keywords in search engines might stumble upon this topic, and it not work for them. So I’d like to expand a little on helping find the resolution to cater for more devs;
OG Question: I would like this countdown to start at 10 then count down to 1, but for the user to see it in real time - this script waits 50 seconds and then shows me all the numbers (1-10). What am I doing wrong here?
The keyword to your question there is start - whats the definition on start? When is your ideal of the countdown starting? @James_Hibbard’s solution is most certainly robust and ideal - but you must remember JS at the end of the document executes once when read. It does not execute when all assets are loaded, thus may execute prematurely.
I know this answer is superfluous to the question, but to add a bit of colour for those who may stumble upon it, you perhaps want to dress your code up with a “DOM Ready” event - or perhaps a document.fonts.ready
event, specifically those prone or reliant to animated timings or with heavy assets such as fonts etc.
The original intention of the question being asked as a PHP question may also serve a different metric of start. In a fire and forget way, triggering a countdown X seconds after a request is a decent way to moderatre a number of requests on an API for example;
Should the OP use time as a metric to inhibit the user from performing an action, then a multiple of dimensions should be accomodated. The delta (value difference between two numbers) of a server request and a browser render is a good way to ensure that adverts are maybe observed for a minimum period of time for example.
For simple UI rate limiting; on page load event after 5 seconds to enable a button is also a cheap way to ensure some basic level of moderation on your application.
TL;DR the idea of start here isn’t always page render, and I provide this comment purely as food for thought.