Ways to render HTML content in the browser with javascript / typescript without frameworks
The code in this repository is loosely based on the following blog tutorial which describes the different ways to render HTML content in the browser using vanilla javascript (typescript in fact) without using front end frameworks or libraries. They use heroes and I use football (soccer) legends randomly pulled from my simple hard-coded database. I follow through and do all the 3 different approaches, although in my opinion the last approach is by far the best one.
Each individual approach is treated as a separate node project. To execute the code in the src directory do the following:
- Navigate to the root-level folder of an approach containing a
package.jsonfile. - Run
npm installto install the development dependencies. There are only two: thetypescriptcompiler andlite-server. Both will be installed locally when you execute this command. - From a terminal either run
npx tsc -wornode_modules/.bin/tsc -wto automatically watch for and compile changes in multiple typescript files in the project. - From a separate terminal run
npx lite-serverornpm run devto launch the development server in your browser.