This work is produced by Johan Leitet for the course Client-based Web Programming (1DV022) at Linnaeus University.
All content in this work excluding photographs, icons, picture of course litterature and Linnaeus University logotype and symbol, is licensied under a
Creative Commons Attribution 4.0 International License.
If you change the content do not use the photographs, icons, picture of the course literature or Linnaeus University logotype and symbol in your new work!
At all times you must give credit to: ”Linnaeus university – Client-based Web Programming (1DV022)” with the link https://coursepress.lnu.se/kurs/klientbaserad-webbprogrammering/ and to the Creative Common-license above.
"The browser is a really hostile programming environment."
-- Douglas Crockford,
The JavaScript Programming Language
Icon made by Freepik from www.flaticon.com is licensed under CC BY 3.0
Usage world wide | Usage Sweden | ||
---|---|---|---|
![]() |
Chrome | 69 % (64 %) | 70 % (42 %) |
![]() |
Safari | 10 % (20 %) | 9 % (47 %) |
![]() |
FireFox | 10 % | 7 % ( < 1 %) |
![]() |
Edge | 5 % (-) | 7 % (-) |
![]() |
Samsung internet | - (6 %) | - (10 %) |
![]() |
UC Browser | 3 % (5 %) | - (-) |
![]() |
Opera | 2 % (2 %) | - (< 1 %) |
![]() |
Internet Explorer | 7 % (-) | 4 % (-) |
Sorry, but you are on your own...
Grosskurth, A., & Godfrey, M. (2005). A reference architecture for Web browsers.
Source: Douglas Crockford: An Inconvenient API - The Theory of the DOM
Browser/ rendering Engine |
JavaScript Engine |
|
---|---|---|
![]() ![]() ![]() |
Blink | V8 |
![]() |
Gecko | SpiderMonkey |
![]() |
WebKit | JavaScript Core (WebKit) |
![]() |
Trident | Chakra |
![]() |
.html | Structure |
![]() |
.css | Presentation |
![]() |
.js | Behavior |
Javascript can not:
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<section>
... A lot of content here ...
</section>
<script src="js/app.js"></script>
</body>
src/
|-js/
|-app.js
|-index.html
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<script>
console.log('Testing out js in the browser')
</script>
<section>
... A lot of content here ...
</section>
</body>
<script>
<script async>
<script defer>
http://www.growingwiththeweb.com/2014/02/async-vs-defer-attributes.html
An example of a folder structure
src/
|-js/
|-app.js
|-css/
|-index.html
In the browser there are no modules by default.
Everything is global on the object "window"
app.js
let temp = 22
function myFunction(){
increaseTempBy = 12
temp += increaseTempBy
}
console.log(window.temp) // 22
console.log(window.increaseTempBy) // 12
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<script type="module" src="js/app.js"></script>
</head>
<body>
<section>
... A lot of content here ...
</section>
</body>
src/
|-js/
|-app.js
|-index.html
bar.js
import { a as b } from './foo.js'
import { a } from './foo.js'
import * as nspace from './foo.js'
console.log(nspace.a)
foo.js
export { a as b }
export { a }
export let c
app.js
import { MyClass } from './MyClass.js'
new MyClass()
MyClass.js
export class MyClass {
constructor(){
}
}
app.js
import MyClass from './MyClass.js'
new MyClass()
MyClass.js
export default class MyClass {
constructor(){
}
}
index.html
<head>
<script type="module" src="js/app.js"></script>
</head>
<body>
...
<script nomodule src="build.js"></script>
</body>
app.js
import MyClass from './MyClass.js'
new MyClass()
MyClass.js
export default class MyClass {
constructor(){
}
}