Skip to content

Commit

Permalink
js in html
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonLaster committed May 5, 2017
1 parent 19041e7 commit cf00efd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
| [clojurescript - hello](./examples/clojurescript/hello.html) | |
| [coffeescript - tutorial](./examples/coffeescript/tutorial) | |
| [Create React App - (jsx, flow)](./examples/my-app/build) | |
| [JS in HTML](./examples-js-in-html.html) | A webpage with several inline scripts |
| [asm.js](./examples/asm.html) | |
| [wasm](./examples/wasm/fib/fib.index.html)||

Expand Down
42 changes: 42 additions & 0 deletions examples/js-in-html.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<html>
<head>
<script type="text/javascript">
var globalObject = {
first: 'name',
last: 'words',
};
function sayHello(name) {
return `Hello, ${name}!`;
}
</script>
<style>
BODY {
font-size: 48px;
color: rebeccapurple;
}
</style>
</head>
<body>
<h1>Testing Script Tags in HTML</h1>
<script>
const capitalize = name => {
return name[0].toUpperCase() + name.substring(1);
};
const greetAll = ['my friend', 'buddy', 'world']
.map(capitalize)
.map(sayHello)
.join('\n');

globalObject.greetings = greetAll;
</script>
<p>
Some arbitrary intermediate content to affect the offsets of the scripts
</p>
<script>
(function iife() {
const greeting = sayHello('Ryan');
console.log(greeting);
})();
</script>
</body>
</html>

0 comments on commit cf00efd

Please sign in to comment.