‣
‣
User refers to the person
‣
User Agent is the software or a software agent that acts on behalf of a user, such as a web browser that "retrieves, renders and facilitates end user interaction with Web content". An email reader is a mail user agent.
I.O.W. A user-agent is the browser or mobile application
‣
Client is the application code
‣
Doctype do?- Doctype stands for Document Type Declaration.
- Which informs the web browser about the type and version of HTML used in building the web document. This allows the browser to load it properly.
- The DOCTYPE declaration for the HTML5 standards is
<!DOCTYPE html>.
‣
- When an HTTP request is made to a server, the requesting user agent usually sends information about language preferences, such as in the
Accept-Languageheader. - The server can then use this information to dynamically generate and return a version of the document in the appropriate language
- Server uses the HTML markup will contain
i18nplaceholders and content for the specific language stored inY(A)MLorJSONformats. - The returned HTML document should also declare the lang attribute in the
<html>tag, such as<html lang="en">...</html>
‣
‣
- Calendar dates are sometimes presented in different ways. Eg. "May 31, 2012" in the U.S. vs. "31 May 2012" in parts of Europe.
- Text in raster-based images (e.g. png, gif, jpg, etc.), is not a scalable approach
- Using the
lang attribute in your HTML. - Directing users to their native language and allowing a user to change his country/language easily without hassle.
‣
- Some content can be longer when written in another language.
- Be wary of layout or overflow issues in the design. It's best to avoid designing where the amount of text would make or break a design. Character counts come into play with things like headlines, labels, and buttons. They are less of an issue with free-flowing text such as body text or comments.
‣
- English is left-to-right, but some languages are up-to-down, right-to-left
‣
cookie vs sessionStorage vs localStorage‣
cookies are strings are stored in the browser, which are generally used for authentication.- 4kb storage limit
- set by the
Set-CookieHTTP header - accessed via
document.cookie - Expiry is determined by the server
‣
sessionStorage is a storage object of key-value pairs (both strings)- 5mb storage capacity
- set by
window.sessionStorage.setItem() - Expires upon tab/page close
‣
localStorage is a storage object of key-value pairs (both strings)- 5mb storage capacity
- set by
window.localStorage.setItem() - Does not expire, can be set by server
‣
<script> vs <script async> vs <script defer>? ‣
<script>- HTML parsing is blocked, the script is fetched and executed immediately, HTML parsing resumes after the script is executed.
‣
<script async>- The script is fetched in parallel to HTML parsing
- Executed as soon as it is available (potentially before HTML parsing completes).
- UseÂ
async when the script is independent of any other scripts on the page, for example, analytics.
‣
<script defer>- The script will be fetched in parallel to HTML parsing
‣
- If there are multiple of them, each deferred script is executed in the order they were encounÂtered in the document.
- UseÂ
defer if the script relies on a fully-parsed DOM. There's not much difference in putting a normalÂ<script> at the end ofÂ<body>. - A deferred script must not containÂ
document.write.
‣
<link>s between <head></head>? ‣
💡
CSS is a render blocking resource, because without CSSOM there’s no Render Tree, and without Render Tree there’s no render.
- When a page first loads, HTML is parsed and is transformed progressively into the DOM
- When the
<link>tag is found, a new request for the style sheet is made. - After which the CSS is transformed into the CSSOM
- Finally, the page is rendered, i.e. this is the
First Meaningful Paint(the the time it takes for the primary content of a page to be shown)
- To prevent flashes of unstyled content (FOUC)
- Some browsers block re-rendering to avoid having to repaint elements of the page if their styles change. The user is then stuck viewing a blank white page.
‣
‣
<script>s just before </body>? Do you know any exceptions?<script>s block HTML parsing while they are being downloaded and executed.- If your
<script>manipulates DOM elements, your code could throw an error and halt the entire script - Placing the scripts at the bottom will allow the HTML to be parsed and displayed to the user first.
‣
- If you NEED to put
<script>in the<head>, use thedeferattribute, which will achieve the same effect of downloading and running the script only after the HTML is parsed
‣
- Progressive rendering is a collection techniques used to improve the performance, or perceived load time, of a webpage to render content for display as quickly as possible.
Examples of progressive rendering techniques include:
‣
- Images on the page are not loaded all at once. JavaScript will be used to load an image when the user scrolls into the part of the page that displays the image.
‣
- Include only the minimum CSS/content/scripts necessary for the amount of page that would be rendered in the users browser first to display as quickly as possible, you can then use deferred scripts or listen for theÂ
DOMContentLoaded/load event to load in other resources and content.
‣
- Flushing parts of the HTML to the browser as the page is constructed on the back end. More details on the technique can be found here.
‣
srcset attribute? Why would you use it?The srcset attribute allows different images to be served to users depending on the client's resolution/device width.
‣
<img srcset="small.jpg 500w, medium.jpg 1000w, large.jpg 2000w" src="..." alt=""> tells the browser to display the small, medium or large .jpg graphic depending on the client's resolution.For a device width of 320px, the following calculations are made:
500 / 320 = 1.56251000 / 320 = 3.1252000 / 320 = 6.25- So the client's resolution is 1x, 1.5625 is the closest, and 500w corresponding to small.jpg will be selected by the browser.
‣
data- attributes used for?- Were originally used to store additional data in the DOM
- These days,
data-attributes are used as hooks for end-to-end testing frameworks without having to add additional classes or ids
‣
rel="noopener" attribute used?‣
‣
‣
<header>, <article>, <section> , <footer>‣
<header> elements? What about <footer> elements?