External javascript method 1
external javascript method 1
serving with html
- by opening
index.html
- create your html file and save it (e.g.
index.html) - write your js code in a file (e.g.
client.js) - preprocess that file with
browserify(e.g.browserify client-before -o client-after.js) index.htmlpoints toclient.js
external synchronous
1x html file, 1x js file
html file runs, calling the (browserified) app.js file
-
source code transformation — either ahead of time (webpack and browserify) or at runtime (nodular) -
multiple requests (because its multiple files to call)
-
the resultant javascript is injected into the html and run as if it is a single html file (after joining it together through multiple requests)
-
*if not using external libraries, then just point to your
app.jsfile. -
*if using external libraries (through node) to use
require("someLibrary")(which is actually a node.js method), run browserify on it. source
how?
Browserify parses the AST for require() calls to traverse the entire dependency graph of your project.
- this is because you don’t use node.js to run it, but rather you run the entire html (and js with the node-specific methods) through the web browser.