Frontend Questions Flashcards
Why might you choose an iFrame over XHR for communicating with the server?
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.
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?
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)
Can you write a DOM traversal without using JQuery or other third-party libraries? Why would you want to?
?
Loading an entire library might not be necessary / hinder user experience.
Which DOM API calls are slow and what alternatives do you have for them?
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.
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?
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)
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?
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 do you make an AJAX app back-button aware in different browsers, and how will HTML5 help this?
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 might you track that a user has clicked on a link, and again, how might HTML5 help this?
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>
Do you know about Canvas, localStorage/sessionStorage, the tag, WebGL, and various other HTML5 goodies?
?
How do you write custom attributes on HTML tags in HTML5?
With the data-attribute
What is HTTP?
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.
What is an HTTP client?
A browser is an HTTP client because it sends requests to an HTTP server (Web server), which then sends responses back to the client.
What are “Resources”?
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.
Describe 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).
Describe how an HTTP request works
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).