superblocks-lab
superblocks-lab copied to clipboard
In DApp HTML file insert JS/CSS at end of HEAD tag instead of substituting placeholders
Summary
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/jquery.js"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/web3.min.js"></script>
<!-- JAVASCRIPT -->
<!-- STYLE -->
</head>
<body>
<h1>Hello World DApp</h1>
<h2>Message: <span id="message"></span></h2>
</body>
</html>
The <!-- JAVASCRIPT -->
and <!-- STYLE -->
are now substituted with the generated JS and CSS when the DApp is rendered. We could instead add the JS/CSS before the </head>
tag to make it work without the substitution placeholders.
Motivation
If the substitution placeholders are missing then the dapp will not work.
@Bashlund actually doing so will limit the ability for the developer to change where exactly the code should be injected in the HTML.
As an example, Vue.js requires that your JS code actually gets placed at the bottom of the body, after your HTML and placeholders
as a developer you still have control of where the app.js
will be injected, which is a good thing :)