CS102: Monsoon 2015
1 Course updates Project user understanding phase: writeup due - - PowerPoint PPT Presentation
1 Course updates Project user understanding phase: writeup due - - PowerPoint PPT Presentation
CS 102 Human-Computer Interaction Lecture 12: HTML, HTTP, CSS and Javascript CS102: Monsoon 2015 1 Course updates Project user understanding phase: writeup due Monday Oct 12 Home page for each student due Wednesday Oct 14 (email zip fi le
CS102: Monsoon 2015
Course updates
Project user understanding phase: writeup due Monday Oct 12 Home page for each student due Wednesday Oct 14 (email zip file to us) WWW conference (submissions due in Oct, conference in April/May the following year)
2
CS102: Monsoon 2015
Reminder: HTML & CSS Intro
https://www.codecademy.com/en/tracks/htmlcss (Complete the whole course)
3
CS102: Monsoon 2015
Recap
4
CS102: Monsoon 2015
HTML and HTTP
5
CS102: Monsoon 2015
Evolution of HTML
Very interesting language features Error tolerant Declarative Non-context-free grammar Dangling links are ok Original idea: Users would be able to edit pages End user customizable
6
CS102: Monsoon 2015
Common HTML tags
<html>, <body> <table>, <tr>, <td> <div>, <span>, <p> <img> <a href=“…”> and <a name=“…”> <form>, <input>, <select> <ul>/<ol>, <li> <h1>…<h6> <iframe>
7
CS102: Monsoon 2015
Inspecting HTML and HTTP
Go to http://ashoka.edu.in
8
Document Object Model
CS102: Monsoon 2015
Cookies: first access
9
CS102: Monsoon 2015
Cookies: second access
10
CS102: Monsoon 2015
HTTP caching
Browser need not fetch previously fetched resources (html, images, CSS, JS) if they have not changed Server can control browser’s caching behavior
11
CS102: Monsoon 2015
Caching: max-age
12
CS102: Monsoon 2015
Caching: max-age
After modification (< 60 seconds)
13
CS102: Monsoon 2015
Caching: max-age
After modification (> 60 seconds)
14
CS102: Monsoon 2015
Caching: first access
15
CS102: Monsoon 2015
Caching: second access
Browser need not fetch previously fetched resources (html, images, CSS, JS) if they have not changed Server can control browser’s caching behavior
16
CS102: Monsoon 2015
Compression
(needs server setup)
17
CS102: Monsoon 2015
Compression
18
CS102: Monsoon 2015
Ajax request
19
CS102: Monsoon 2015
Ajax response
20
CS102: Monsoon 2015
HTTP performance tips
21 http://stevesouders.com/examples/rules.php
CS102: Monsoon 2015
HTTP performance tips
- 1. Make fewer HTTP requests
- 2. Use a CDN
- 3. Add an expires header
(max-age)
- 4. Gzip components
5 & 6. Put stylesheets at the top, scripts at the bottom.
- 7. Avoid CSS expressions
22
- 8. External CSS and JS
- 9. Reduce DNS lookups
- 10. Minify Javascript
- 11. Avoid redirects
- 12. Remove duplicate scripts
- 13. Configure Etags
- 14. Make AJAX cacheable
CS102: Monsoon 2015
CSS
23
CS102: Monsoon 2015
Cascading style sheets
HTML is for content, CSS is for display Declarative syntax “Aspect-oriented” design Styles cascade in specified order Neat separation of View from Model
24
CS102: Monsoon 2015 25 http://csszengarden.com/
CS102: Monsoon 2015
Basic CSS bindings
Format: selector { prop1: val1; prop1: val1 } Selectors: tags, classes, ids, … div { color: green; } .my_class { color: green; } #my_class { color: green; } …
26
<div>…</div> <div class=“my_class”>…</div> <div id=“my_id”>…</div>
CS102: Monsoon 2015
Basic CSS properties
Box properties (padding, margin, border) Color and background Font and text (letter spacing, line-height, …) Visual layout (display, float, dimensions, z-index, …) Pagination, cursor, etc. (Lots more in CSS 3)
27
CS102: Monsoon 2015
CSS box model
28
CS102: Monsoon 2015
Playing with CSS
29