SuperblocksHQ / superblocks-lab

Superblocks Lab for DApp development
https://superblocks.com/lab/
GNU General Public License v3.0
99 stars 37 forks source link

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

Open bashlund opened 5 years ago

bashlund commented 5 years ago

Summary

<!DOCTYPE html>
<html lang="en">
    <head>
        <script type="text/javascript" src="https://unpkg.com/jquery@3.3.1/dist/jquery.js"></script>
        <script type="text/javascript" src="https://unpkg.com/web3@0.20.5/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.

javier-tarazaga commented 5 years ago

@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 :)