Anyway, recently I struggled again, but this time I don’t have the energy to be stubborn, I googled for solution.
- Use SCRIPT tag to load the .js file
- Add another SCRIPT tag to execute any initiation functions
It will be something like this
That’s all, very simple and straighforward indeed. So now looking back, what’s wrong with my earlier method anyway? Chronologically speaking, it would be as follows:
- I put the code directly inside a SCRIPT tag
Which is really horrible, considering that:
- my code is now unreadable to human 😀
- I must tirelessly replace all single line comments (// …. ) into multiple line style ( /* …. */ )
- It makes debugging with Firebug really difficult
Hmmpffhh… I learned my lesson, so let’s move on 😉 Did you ever make similar mistake because of your stubbornness?