superblocks-lab icon indicating copy to clipboard operation
superblocks-lab copied to clipboard

In DApp HTML file insert JS/CSS at end of HEAD tag instead of substituting placeholders

Open bashlund opened this issue 6 years ago • 1 comments

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 avatar Sep 20 '18 13:09 bashlund

@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 , as otherwise, it will simply not work. By using the placeholders as a developer you still have control of where the app.js will be injected, which is a good thing :)

javier-tarazaga avatar Oct 23 '18 13:10 javier-tarazaga