How do web browsers work? | Web Demystified, Episode 5 — transkrypcja

Mozilla’s Web Demystified explains what modern browsers handle — networking, rendering, interactivity, storage and security — and walks through the rendering pipeline: requesting documents, parsing them into trees, computing layout and painting pixels, often 60 times a second.

Oryginalne wideo przez Mozilla Hacks na YouTube. Podpisy mogą zawierać błędy; sprawdź cytaty z nagraniem.

Kluczowe punkty

  • Browsers handle network connections, including HTTP requests, two-way channels with servers and peer-to-peer connections.
  • They parse and execute several languages and render fonts, images, audio and video, all of it interactive.
  • They store data through caching and storage APIs, and sandbox content from different sources for security.
  • Rendering works in four steps: request documents, parse them into internal trees, compute the page layout, then paint pixels.
  • Because pages can change at any time, layout may be recomputed 30 to 60 times a second or more, a demand comparable to high-end games.
  • Interactivity comes from native HTML and CSS behaviour and from JavaScript; knowing what triggers a new layout versus a repaint helps authors build faster pages.

Rozdziały

  1. 0:00Introduction
  2. 0:39What modern browsers have to do
  3. 2:32The rendering pipeline: request, parse, lay out, paint
  4. 4:03Why interactivity makes rendering hard
  5. 4:42Native interactions and JavaScript
  6. 5:22What this means for web authors
  7. 6:01Recap

Źródło i licencja

Film
How do web browsers work? | Web Demystified, Episode 5 · Mozilla Hacks
Przesłano
Licencja
Creative Commons Uznanie autorstwa (CC BY 3.0)
Napisy
Napisy przesłane przez twórcę

Najważniejsze punkty i rozdziały przygotowuje TranscriptYouTube na podstawie transkrypcji. Nie są one weryfikacją twierdzeń mówcy.

Transkrypcja wideo

How do web browsers work? | Web Demystified, Episode 5

Mozilla Hacksangielski7 min1000 słowa4 min odczyt

Oglądaj na YouTube
Eksportuj sekcję

  1. 0:00

    Hello! Welcome to a new episode of Web Demystified.

  2. 0:03

    In the previous episodes we talked about various web technologies at the heart of the web

  3. 0:08

    and we've said that web browsers are mixing things together

  4. 0:11

    in order to display web documents

  5. 0:13

    Yeah, that really sounds like voodoo magic!

  6. 0:16

    Really?

  7. 0:18

    Okay, so today, let's talk a bit more about how browsers work and...

  8. 0:24

    Let's kill the witchcraft.

  9. 0:34

    Browsers are...

  10. 0:39

    Browsers are very complex pieces of software that have drastically evolved since the 90's,

  11. 0:44

    from rendering simple text to executing fully fledged applications.

  12. 0:49

    So what are exactly browsers able to do these days?

  13. 0:54

    First of all,

  14. 0:55

    because the web is all about requesting documents stored on the Internet,

  15. 0:59

    they are able to handle network connections.

  16. 1:02

    Historically, that was done using the HTTP protocol

  17. 1:05

    to perform simple CRUD operations on documents.

  18. 1:08

    But nowadays they can also create bidirectional communication channels with a server

  19. 1:14

    or they can even create a peer-to-peer connections with another browser.

  20. 1:17

    Second, they have to be able to understand, render and/or execute different languages.

  21. 1:23

    They also have to be able to render fonts, images, audio, and videos.

  22. 1:29

    Third, everything you see in a browser must be interactive.

  23. 1:33

    You can select text, scroll pages, click on links, input text, drag and drop content, etc.

  24. 1:41

    Fourth, they can store data, either by caching content

  25. 1:45

    or providing various storage mechanisms.

  26. 1:48

    And all of this must work regardless of the complexity of each page

  27. 1:54

    and regardless of the number of pages open at the same time!

  28. 1:58

    This is…

  29. 2:00

    very challenging

  30. 2:03

    Last but not least, because the Internet remains a wild place

  31. 2:06

    and because websites can aggregate contents from very different sources,

  32. 2:11

    things have to be reasonably secured.

  33. 2:13

    To do that browsers must be able to manage data encryption,

  34. 2:18

    and to sandbox every set of contents

  35. 2:20

    in order to prevent malicious code to access other contents,

  36. 2:23

    or worse, your computer.

  37. 2:25

    And this is just the tip of the iceberg.

  38. 2:29

    So, let's try to keep things simple.

  39. 2:32

    Okay, let's focus on the specific job of a browser, from a high level:

  40. 2:36

    rendering multiple documents to display them to you in an interactive way.

  41. 2:41

    Let’s start with the rendering.

  42. 2:42

    One. The browser requests all the necessary documents

  43. 2:46

    For the sake of example…

  44. 2:47

    let's say we are requesting an HTML document

  45. 2:50

    and its associated stylesheets and images.

  46. 2:53

    Two. All documents will be parsed and turned into machine-friendly representations.

  47. 2:58

    If you do a bit of research here, You'll hear fancy names like

  48. 3:02

    DOM trees, Style trees, Rendering trees, Display lists

  49. 3:07

    these are just different ways for browsers to represent documents.

  50. 3:11

    Three. The intermediate representations are used to compute the whole page layout.

  51. 3:16

    This is where the "mixing all the things" happen.

  52. 3:20

    The browser computes the size, position, and representation

  53. 3:24

    of everything that will be displayed on the page.

  54. 3:27

    In the browser industry, senior engineers who are actually programing layout computations

  55. 3:31

    are often considered true magicians because…

  56. 3:34

    this is very likely one of the most complicated parts of a browser.

  57. 3:37

    Four. The browser finally paints each element of the layout on the screen.

  58. 3:42

    Tadda!

  59. 3:43

    So to summarize:

  60. 3:45

    the browser reads all the documents;

  61. 3:47

    it turns them into several intermediate representations easier to use;

  62. 3:51

    it computes the position of everything on the page;

  63. 3:54

    and it paints each pixel accordingly.

  64. 3:57

    Okay, this is roughly what any piece of software displaying content is doing.

  65. 4:03

    The nuance comes from the interactive aspect of the web:

  66. 4:07

    everything on a web page is dynamic,

  67. 4:10

    meaning it can be changed or animated at will!

  68. 4:13

    So if something is moving on the page,

  69. 4:18

    the full layout must be recomputed at 30 or 60 frames per second, or even more

  70. 4:25

    and regardless of the number of elements on the page.

  71. 4:29

    Actually, the only other types of software that have to face such a challenge

  72. 4:36

    are top of the line triple-A games.

  73. 4:38

    Thanks to that, things can become interactive,

  74. 4:42

    and there are two ways to handle interactivity:

  75. 4:45

    On the one hand there are all the native interactions that the browser is providing,

  76. 4:50

    usually through HTML and CSS.

  77. 4:53

    Remember?

  78. 4:54

    You can select text, scroll pages, click on links, input text, drag and drop content, etc.

  79. 5:02

    On the other hand, there is what JavaScript lets people do.

  80. 5:06

    Fundamentally, JavaScript lets people build any kind of interactivity

  81. 5:10

    by granting them access to the core functionalities of the browsers.

  82. 5:14

    You know, the one we've listed at the beginning of that video…

  83. 5:18

    Yeah, OK, you get it!

  84. 5:19

    The consequence of all of that is that

  85. 5:22

    web authors must learn how browsers work

  86. 5:24

    in order to optimize the experience they want to provide to their users.

  87. 5:28

    For example it is a good idea to learn what triggers a new layout computation

  88. 5:33

    versus a simple repaint, just because the latter is faster than the former.

  89. 5:38

    Unfortunately, It’s hard to get into the details because…

  90. 5:41

    each browser works somewhat differently.

  91. 5:43

    Oh Thanks! That’s soooo helpful!

  92. 5:48

    Well!

  93. 5:49

    There are no big secrets and…

  94. 5:52

    browser makers are working hard to make sure that

  95. 5:55

    even the crappiest web pages are rendered fast and smooth.

  96. 5:58

    But it's a topic for another video.

  97. 6:01

    Okay, let's recap.

  98. 6:03

    Browsers handle a lot of things:

  99. 6:06

    networks, content display, data storage, content security…

  100. 6:11

    all in a very interactive way.

  101. 6:12

    They handle technical requirements

  102. 6:15

    that can be compared to those of super high-end games.

  103. 6:18

    And they give content creators the ability to create any form of interactivity.

  104. 6:23

    Now you shouldn’t consider the web to be magic.

  105. 6:29

    it’s just clever computer science.

  106. 6:32

    Thank you all for watching this episode.

  107. 6:35

    If you want to get into the nasty details of browser internal working,

  108. 6:39

    I suggest that you have a look at this amazing talk by Tali Garsiel

  109. 6:43

    In the meantime, if you enjoyed this episode

  110. 6:45

    feel free to like it and to share it with your friends.

  111. 6:48

    The more, the merrier!

  112. 6:49

    To continue the discussion feel free to comment down below

  113. 6:51

    or join me and my colleagues on Twitter.

  114. 6:53

    And finally…

  115. 6:55

    Long live the open web, see you next time!