Frontend Questions Flashcards

1
Q

Why might you choose an iFrame over XHR for communicating with the server?

A

Supposedly iframes have less overhead than making a new XHR/HTTP request to reconnect after every message, but when I tried it all I saw was increased memory overhead on my server and zero responsiveness improvement; probably it depends on your choice of backend.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are some ways that you can get JavaScript onto a third-party website that can then communicate with your server and display some data on their website?

A

One method that looks bullet-proof is what olark has done: https://github.com/olark/lightningjs Takes care of xhtml vs html, bad code, bad browsers and lots of other stuff (performance)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Can you write a DOM traversal without using JQuery or other third-party libraries? Why would you want to?

A

?

Loading an entire library might not be necessary / hinder user experience.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which DOM API calls are slow and what alternatives do you have for them?

A

dom manipulation, append, insert and the like. I always remove the parent element and then put it back in when I’m done with it. innerHTML is also fast and appropriate sometimes.

Also, adding new CSS rules to the page is really slow because it forces a reflow. Basically anything that forces a reflow and makes the browser repaint the whole page will be slow.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Say that you have too many CSS rules for IE and need to come up with a quick fix that doesn’t involve refactoring your CSS into something more sane or reducing the number of CSS rules. How might you do this?

A

IE6-8 has a limit of 4095 CSS selectors in a single stylesheet. Simply to break the CSS up into multiple tags (or stylesheets, if you’re using external CSS)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which tags are self-closing in HTML5? Which tags may be omitted entirely? You can look them up, but which site would you go to?

A

self closing: input, br, hr, meta, link, img, li, dl, dt, tr, td, th, ect

omitted entirely: html? body?

the official spec at WhatWG.com

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you make an AJAX app back-button aware in different browsers, and how will HTML5 help this?

A

Use location.hash. I wouldn’t know how to implement it my self (IE needs an iframe from what I understand, Safari has/ad its own issues) but there are a bunch of libraries out there to do it for me. HTML5 has pushState, yay!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How might you track that a user has clicked on a link, and again, how might HTML5 help this?

A

For logging, there’re a bunch of alternatives like going through a redirect or or adding some JS that makes an XHR or image request, but the HTML5 solution is <a>, which unfortunately is still buggy in most browsers.</a>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Do you know about Canvas, localStorage/sessionStorage, the tag, WebGL, and various other HTML5 goodies?

A

?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you write custom attributes on HTML tags in HTML5?

A

With the data-attribute

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is HTTP?

A

HTTP stands for Hypertext Transfer Protocol. It’s the network protocol used to deliver virtually all files and other data (collectively called resources) on the World Wide Web, whether they’re HTML files, image files, query results, or anything else. Usually, HTTP takes place through TCP/IP sockets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is an HTTP client?

A

A browser is an HTTP client because it sends requests to an HTTP server (Web server), which then sends responses back to the client.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are “Resources”?

A

HTTP is used to transmit resources, not just files. A resource is some chunk of information that can be identified by a URL (it’s the R in URL). The most common kind of resource is a file, but a resource may also be a dynamically-generated query result, the output of a CGI script, a document that is available in several languages, or something else.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Describe the client-server model

A

An HTTP client opens a connection and sends a request message to an HTTP server; the server then returns a response message, usually containing the resource that was requested. After delivering the response, the server closes the connection (making HTTP a stateless protocol, i.e. not maintaining any connection information between transactions).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Describe how an HTTP request works

A

HTTP uses the client-server model.

An HTTP client opens a connection and sends a request message to an HTTP server; the server then returns a response message, usually containing the resource that was requested. After delivering the response, the server closes the connection (making HTTP a stateless protocol, i.e. not maintaining any connection information between transactions).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the format of an HTTP request?

A

The format of the request and response messages are similar, and English-oriented. Both kinds of messages consist of:

  • an initial line,
  • zero or more header lines,
  • a blank line (i.e. a CRLF by itself), and
  • an optional message body (e.g. a file, or query data, or query output).

Put another way:

Header1: value1
Header2: value2
Header3: value3

17
Q

What is the format of an HTTP response?

A

The format of the request and response messages are similar, and English-oriented. Both kinds of messages consist of:

  • an initial line,
  • zero or more header lines,
  • a blank line (i.e. a CRLF by itself), and
  • an optional message body (e.g. a file, or query data, or query output).

Put another way:

<initial line, different for request vs. response>
Header1: value1
Header2: value2
Header3: value3

<optional message body goes here, like file contents or query data;
it can be many lines long, or even binary data $&*%@!^$@>

18
Q

What is a MIME-type?

A

a label for a given type of data so software can know how to handle the data. It serves the same purpose on the Internet that file extensions do on Microsoft Windows.

example MIME-types: text/html or image/gif

19
Q

What is an HTTP proxy?

A

An HTTP proxy is a program that acts as an intermediary between a client and a server. It receives requests from clients, and forwards those requests to the intended servers. The responses pass back through it in the same way. Thus, a proxy has functions of both a client and a server.

20
Q

What is AJAX?

A

Asynchronous JavaScript + XML, while not a technology in itself, is a term coined in 2005 by Jesse James Garrett, that describes a “new” approach to using a number of existing technologies together, including: HTML or XHTML, Cascading Style Sheets, JavaScript, The Document Object Model, XML, XSLT, and the most importantly XMLHttpRequest object.
When these technologies are combined in the AJAX model, web applications are able to make quick, incremental updates to the user interface without reloading the entire browser page. This makes the application faster and more responsive to user actions.

21
Q

What are WebSockets?

A

The HTML5 WebSocket specification defines an API establishing “socket” connections between a web browser and a server. In plain words: There is an persistent connection between the client and the server and both parties can start sending data at any time

22
Q

What is long polling and why is it used?

A

One of the most common hacks to create the illusion of a server initiated connection is called long polling.

With long polling, the client opens an HTTP connection to the server which keeps it open until sending response. Whenever the server actually has new data it sends the response (other techniques involve Flash, XHR multipart requests and so called htmlfiles). Long polling and the other techniques work quite well. You use them every day in applications such as GMail chat.

23
Q

What are some problems with the traditional request/response paradigm of HTTP?

A

A client loads up a web page and then nothing happens until the user clicks onto the next page. Around 2005, AJAX started to make the web feel more dynamic. Still, all HTTP communication was steered by the client, which required user interaction or periodic polling to load new data from the server.

24
Q

What is new in HTML5?

A

New structure:
, , , , , ,

New inline elements:
, , ,

New dynamic pages support:

  • context menus
  • href is not a required tag (allows you to use the a tag with scripts and in Web applications without needing a place to send that anchor)
  • async attribute (added to the script tag to tell the browser that the script should be loaded asynchronously so that it doesn’t slow down the load and display of the rest of the page)
  • provides details about an element. This would be like tooltips in non-Web applications.
    • creates a table that is built from a database or other dynamic source

New form types:
datetime, datetime-local, date, month, week, tume, number, range, email, url

New elements:
, ,

Removes some old elements

25
Q

What are you excited about learning in HTML5?

A

?

26
Q

What is new in CSS3?

A

Functions such like opacity, Text-overflow, media queries and box shadows.

Rounded corners, background decoration, colors (HSL, HSLA and RGBA), text effects, attribute matching, box model, web fonts

27
Q

What problem(s) do WebSockets solve?

A

a chatroom, realtime updating, multiplayer games, ect.

There is an persistent connection between the client and the server and both parties can start sending data at any time.

28
Q

What is XMLHttpRequest?

A

a JavaScript object that was designed by Microsoft and adopted by Mozilla, Apple, and Google. It’s now being standardized in the W3C. It provides an easy way to retrieve data at a URL. Despite its name, XMLHttpRequest can be used to retrieve any type of data, not just XML, and it supports protocols other than HTTP (including file and ftp).

29
Q

In HTML5 why can you use <!doctype html>?

A

It can be this simple because HTML 5 is no longer part of SGML

30
Q

What is SGML?

A

The Standard Generalized Markup Language is an ISO-standard technology for defining generalized markup languages for documents.

HTML, XHTML, and XML are all examples of SGML-based languages. HTML5 steps away from SGML a bit.

31
Q

What is the difference between JSON and XML?

A

The fundamental difference, which no other answer seems to have mentioned, is that XML is a markup language (as it actually says in its name), whereas JSON is a way of representing objects (as also noted in its name).

32
Q

What is the difference between NoSQL and SQL?

A

SQL is a relational.

33
Q

What is the difference between MySQL and PostgreSQL?

A

?

34
Q

What is the difference between Memcached and Redis?

A

?

35
Q

What is the latest published revision of the ECMAScript Language.

A

ECMAScript 5.1, the latest published revision of the Language Specification.

36
Q

What source(s) do you use/follow when writing HTML?

A

the official spec at WhatWG.com

37
Q

What is the HTML5 <a> attribute?</a>

A

The ping attribute, if present, gives the URLs of the resources that are interested in being notified if the user follows the hyperlink