Utmaningar

Denna vecka körde vi ett uppdelat fredagshäng. Vi började med en Peer Instruction. Efter detta diskuterades frågor som kommit upp gällande en applikations felkoder.

F01. What is true regarding communication over HTTP? (multiple choice)

  1. The server initiates the request to the client.
  2. The server sends a response to the client's request.
  3. The client sends a response to the server request.
  4. The client initiates the request to the server.
Kommentar

Klienten initierar förfrågan (request) till servern som sedan skickar ett svar (response) på denna förfrågan. 2 och 4.

F02. In what order do the scripts execute in a modern browser?

  1. script1, script2, script3, script4
  2. script3, script4, script5, script1, script2
  3. script3, script4, script1, script2
  4. script1, script2, script4, script3
Kommentar

HTML-tolken tolkar HTML-sidan uppifrån och ner. När den kommer till skripten i head-elementet så laddas dessa in men exekveringen skjuts upp tills parsningen av sidan är genomförd. Skripttaggen som påträffas i bodyn tvingar HTML-tolken att avbryta HTML-tolkningen och skriptet där exekveras (script3). Samma sak inträffar vid script4. script5 ignoreras då vi enligt frågan är i en "modern webbläsare". När väl HTML-tolken är klar så startar exekveringen av script1 följt av script2.

  1. The code can not be cached in an optimal way.
  2. They are less secure.
  3. The script will block DOM parsing.
  4. The code will be harder to maintain.
  5. Visual Studio Code has no color coding support for inline scripts.
  6. They often do not work.
Kommentar

Korrekt svar: 1, 3, 4

F04. What does it mean that a script is deferred? (<script defer>)

  1. The script is executed as soon as the DOM parser find the script tag.
  2. The scripts execution is postponed until the DOM parsing is done.
  3. The scripts loading is postponed until the DOM parsing is done.
  4. The scripts loading is done immediately, and the execution is done when the loading is done
Kommentar

Korrekt svar: 2