Variables, ID & Class
All JavaScript variables shall be written in either completely lowercase letter or camelCase. All id and class declarations in CSS shall be written in only lowercase. Neither dashes nor underscores shall be used.
Event Delegation
When assigning unobtrusive event listeners, it is typically acceptable to assign the event listener directly to the element(s) which will trigger some resulting action. However, occasionally there may be multiple elements which match the criteria for which you are checking, and attaching event listeners to each one might negatively impact performance. In such cases you should use event delegation instead.
jQuery's delegate() is preferred over live() for performance reasons.
Debugging
Even with the best of validators, inevitably browser quirks will cause issues. There are several invaluable tools which will help to refine code integrity and loading speed. It is important that you have all of these tools available to you, despite the browser you primarily use for development. We recommend developing for Firefox and Safari first, then Google Chrome and Opera, with additional tweaks via conditional comments just for Internet Explorer. The following is a list of helpful debuggers and speed analyzers...
Accessibility
Section 508 Standards for intranet and internet information and applications. Interfaces developed by Isobar should meet Section 508 standards.
W3C checklist of checkpoints for accessibility. Interfaces developed by Isobar should meet Priority 1 guidelines.
The WCAG 1.0 Guidelines.
Performance
Optimize Delivery of CSS and JavaScript
There are many optimizations that should be done for serving css and javascript in Production:
- Follow the Yahoo Performance Guidelines
- Smush images using smush.it. Also using YSlow can autosmush all your images for you.
- Set caching headers appropriately.
- Consider a cookie-less subdomain for static assets
- Avoid inline <script> blocks.
- CSS should be located in the
<head> of the document, Javascript should be right before the </body> tag.
- Both CSS and JavaScript should be served minified. Most people use the YUI Compressor for this.
- Both should be served using gzip on the wire
- CSS should be concatenated together. Obviously this can only be done for files that share the same media type (e.g. screen or print). The general goal here is to reduce the number of HTTP connections to dependencies during the loading of the page.
- JavaScript should be concatenated. While a ajax script dependency manager would be ideal (similar to the YUI 3 Loader), it's rather complicated to implement. In its place I'd recommend a singular download of most of the script used on the site. (Of course, proper caching should be used to retain the file as long as is reasonable)
- Concatenation and minification typically occur during an automated build process, when packaging the code for deployment on stage or production. Many use tools like Ant or Maven for this
- Avoid inline
<script> blocks within the HTML. They block rendering and are quite devastating to page load time.
Optimize JavaScript execution
During a page load, there is typically a lot of script waiting to execute, but you can prioritize it.
This order prioritizes based on user response:
- Script that changes the visible nature of the page needs to fire absolutely first. This includes any font adjustment, box layout, or IE6 pngfixes.
- Page content initialization
- Page header, topnav and footer initialization
- Attaching event handlers
- Omniture, Doubleclick, and other 3rd party scripts
Leverage CSS Sprites
CSS Sprites basically take a number of image assets and merge them together into a singular image file. Each part of it is revealed using CSS background-position. Some typical CSS would look like:
It's quite common to leverage sprites for :hover states. In that case you'll see something like:
Using sprites reduces total page weight and reduces HTTP connections which speeds up page load. More on the general technique and overview at css-tricks.com
Many developers use a vertically-oriented sprite in addition to the primary sprite. This vertical sprite will be <=100px wide (and tall) and contain icons that are typically placed next to text, such as list item bullets. Yahoo uses a few such as this one.
The one consideration is to not make sprites too large, something over 1000px in either direction will end up using a sizeable amount of memory. More detail about sprites and memory usage here.
Image formats
There are four main image formats that should be used, detailed here:
JPEG. This will cover all photography-based images, such as homepage and category page promo images, or anything with a very high color count.
-
PNG24. This format, easily accessible in Photoshop, outputs high-color count imagery and fully supports graded opacity by pixel. Relatively, it's quite a heavy format as far as kilobyte weight. It is the only format that IE6 needs to execute a pngfix on. In that case, Isobar recommends the DD_belatedPNG script (A pngfix fixes the issue where PNG24's appear to have a grey or light-blue background in IE6. They are not always compatible with background-position.)
In many cases, you can use a GIF fallback for IE6, in place of a PNG24. This is especially true if any sprites need to be done in PNG24. All pngfixes are very slow and expensive, so it's best to avoid using them.
- PNG8.
A surprising diversity of color can be captured inside 256 colors, so it's worth trying PNG before heading JPG. PNG also is a lot more compressible than GIF (using tools like pngcrush and pngquant). This format allows graded opacity in nearly all browsers, but in IE6, those semi-opaque pixels are just shown 100% transparent. In many cases this is sufficient. It also does not require a pngfix script to be run, so it's optimized for speed.
Photoshop cannot output these semi-opaque files correctly but Fireworks can. More detail here:
http://www.sitepoint.com/blogs/2007/09/18/png8-the-clear-winner/
Transparent GIF 89a. GIF 89a offers the flexibility of transparency and wide browser support, but the constraints of no graded opacity nor a color depth above 256. In our experience, color depths of 64 still provide very good quality thumbnails, and keep the file size comparably very small.
All low-color count imagery such as icons or thematic graphics should be done in PNG8, as it's the most size-efficient of these four. PNG8 is our primary recommendation for most site graphics.
For further optimization all of these formats, taking them through Yahoo's Smush.It will reveal how they can be smaller.
Caching
For static content, the browser should cache the file locally as long as is reasonable.
Content that should have far future caching includes:
- CSS and JavaScript
- product images
- thematic graphics
- favicon.ico
- flash .swf's
- promo images (lighter caching likely)
For the best caching, leverage the Expires http header. This is a far future Expires header, telling the browser that this response won't be stale until April 15, 2015.
Expires: Thu, 15 Apr 2015 20:00:00 GMT
If your server is Apache, use the ExpiresDefault directive to set an expiration date relative to the current date. This example of the ExpiresDefault directive sets the Expires date 1 year out from the time of the request.
ExpiresDefault "access plus 1 year"
Expires http header should be set to a value between one month from present to a year (far future) from present.
Caching only applies to that exact URL, so a change in the filename of any asset will start a fresh copy. Many developers use a build process to add a version number or timestamp to their assets. Each subsequent build will start a brand new cached version, allowing you to use far future cache dates without worry. Google has a lot more detail on browser caching
Shard resources across domains
Static content should certainly be served from a domain different than the one that serves HTML. This is optimal so that there are no extra cookies headers on all static content requests. It's also much easier to write caching rules for the entire domain. (Also any subdomains of the current domain will inherit domain cookies, so it's worth using a completely new domain)
However with enough assets (especially images) the number of requests grows enough to slow down the load of the page. Many browsers have a low constraint of how many assets they will download simultaneously per domain. (In IE6 and 7, it's only two)
In this case, we can serve the assets from multiple subdomains such as:
- static1.otherdomain.com
- static2.otherdomain.com
- static3.otherdomain.com
More information on domain sharding on Google Speed
Avoid IFRAMEs
Iframes are the most costly element to add to a given page. They block the page from firing the onload event until they are complete.
Sometimes they are useful to let another agency handle tracking scripts. For example the Doubleclick floodlight tag is an iframe, and the admin can add tracking pixels into it from their dashboard. In any case where an iframe is added, it should be appended to the DOM dynamically after window onload has fired. More detail at Yahoo's Performance site.
3rd Party Integration
Omniture
We recommend to add the Omniture JavaScript code to the DOM using JavaScript after the page has loaded (either a DOM ready event or window's load event). Using this technique, there is no external domain script dependency, which can slow down (and potentially hang) a page load.
Isobar has a jQuery Omniture plugin that incorporates this and other techniques; we'd love to share if needed.
Flash
Backup HTML content should be in place of the flash in all cases to maximize SEO value. For XML-driven flash, the backup HTML content should be leveraging the exact same XML file, to ensure data consistency.
All replacements should be done using SWFObject but without inline script tags. SWFObject initialization should fire after the DOM Ready event. Minimum player version should be set to minimum v9, to ensure AS3 compatibility.
Search Engine Optimization
Be aware of SEO best practices
Indexability
We must use semantic markup that's readable and logical when JavaScript and css are off. All page content must be in HTML; we don't want to use iframes or JavaScript for loading initial indexable content.
All links should be to HTML destinations. For example:
<a href="/shelf/jordan/page/2">
instead of <a href="javascript:loadPage(2);">
This lets the page get indexed correctly by search engines as well as allows users to open in new tabs and windows.
Optimization
The title tag should feature target keywords for the unique page. The titles should be unique to each page. Headings (h1,h2,etc) should form an outline of the document and represent the most important keywords for that page.
URLs should be human-readable with primary target keywords present in them:
http://domain.com/mens-shoes/basketball/jordan/jordan-mens-ajf-6-basketball-shoe/
vs
http:// domain.com/ecomm.cfm?view=prod&prodId=23425
Flash and Image Replacement
Always use backup HTML content for flash. All promo images should use CSS-based image replacement instead of alt tags.
For example:
SEO Audit Tool
Isobar and iProspect have been kind enough to provide us access to one of their internal tools for SEO evaluation.
Its output should only be used during internal analysis, but not handed over directly to a client.
First, you create a new client. Each client bucket has no restrictions on the URLs, it's just a means of organization.
After creating the client, you'll want to click in and create a new website audit (or resubmit an existing one)
When creating a new audit:
- Website and homepage url fields will normally match. That's fine.
- Site map url is the HTML sitemap page. (not the xml sitemap)
- Webpage URLs are four or five URLs you'd like to be examined more than the rest (primary landing pages, for instance)
- The Other domains field is optional
After the audit is finished generating, there are three reports available with somewhat overlapping material. The contribution ratings are a general (and potentially outdated) idea of the importance of each aspect.
If you have any questions, contact Ben Leblanc (Isobar)
Google's SEO Report Card
Google's SEO Report Card is an effort to provide Google's product teams with ideas
on how they can improve their products' pages using simple and accepted optimizations. These optimizations are intended to not only help search engines understand the content of their pages better, but also to improve their our users' experience
when visiting their sites. Simple steps such as fixing 404s and broken links, simplifying URL choice, and providing easier-to-understand titles and snippets for their pages can benefit both users and search engines.
Code Reviews
What is a code review?
A code review is the cornerstone of the formal process for ensuring the quality of user experiences developed by the iDev team. This involves a meeting among authors of markup, reviewers and other stakeholders, with expected input and subsequent code revisions.
Why should I have a code review?
Code reviews are a strategic investment of time to mitigate risk on a project.
Oftentimes, interface developers are asked to author markup from wire frames or visual compositions. However, its possible that screens that are designed cannot be translated to markup easily, or without compromising quality. Code reviews provide an opportunity for this risk to be addressed and resolved before full production of pages begins.
Code reviews increase the overall level of knowledge across projects
Since code reviews involve members from within and outside a project team, techniques and best practices are easily shared throughout the entire iDev team.
Code reviews eliminate bugs before they are reproduced from a few templates into multiple pages
Ideally, code reviews are conducted early in the development process, before full production of pages begins. When templates are reviewed by the team and run through multiple validation tools and browsers, bugs can and will appear. This is the ideal time for bugs to be fixed.
Code reviews give a set of fresh eyes an opportunity to spot issues with code
Reviewers from outside a project team can spot issues with code more easily than authors of markup, who have been working with code for a longer amount of time.
Who should participate in a code review?
Ultimately, the iDev Lead on a project is required to ensure that proper code review procedures are followed.
Ideally, a practice lead should act as facilitator for a code review session, unless the practice lead is also the interface developer whose code is under review. In this situation, a project manager can be brought in as a facilitator.
The review team should include at least two senior members of the Interface Technology team versed in development and best practices.
What is required for a code review?
Before a code review is conducted, templates to be reviewed must be fully developed, validated, and tested against the browsers and platforms required by the project.
A practice lead and/or interface developer must distribute the following 48 hours prior to the date of the code review:
-
Code for all pages, associated server-side includes, CSS, and JavaScripts. These should be fully commented, printed out with line numbers along the left side, and the file/page name in the footer of each printed page.
-
Screenshots of each template
-
URLs of the templates, if applicable
-
A list of browsers and platforms supported by the project
-
A list of known issues/areas of concern
It is typical for code to be changed constantly until the code review is to take place. Unfortunately, this does not leave enough time for validation and testing. If this is the case, it is recommended that the code review be rescheduled to a date that ensures a proper code review.
In addition, a practice lead and/or interface developer should book a conference room and call-in number for all attendees, since it is possible that members of either the project or code review team are off-site. An hour should provide enough time for review of two or three templates; however, time will vary depending on the volume and complexity of the templates.
During the code review, a practice lead and/or interface developer should facilitate the meeting, while the practice lead or project manager takes notes and assigns action items. Reviewers should have reviewed the code and come prepared to ask questions or provide feedback.
Notes and action items (including owners) should be distributed to all attendees after the code review. If substantial changes come out of a code review, or all code is not reviewed, it may be necessary to schedule a second code review. However, this should be discussed amongst the project team to determine feasibility.
Browser Testing and Support
What we support
Isobar supports any browser with an A-Grade in Yahoo's Graded Browser Support, with the exception of Opera. There may be exceptions to this, given regional markets and their particular metrics.
We will strive to support any other mission critical browsers mandated by the client (IE 5.5, Opera, Konqueror, Safari 3 on PC, etc), though we cannot guarantee all functionality is possible.
How we test
IE Testing
Firefox
Safari
Opera
Bugs in standalone versions
Note: The IE6 standalone has a buggy implementation of opacity in some cases. This will result in any opacity applied with a CSS filter, like alpha opacity or a 24-bit PNG, to fail. In the case that opacity must be tested, you will need a native IE6 installation.
It has been noticed that IE 7 using the Vista platform does have differences from IE 7 on Windows XP, therefore, you might want to make sure that someone on your team has this configuration as well. IETester is known to fix a number of these issues, as do the Xenocode browsers.
Browsertesting network machine
We also have a machine on the network with three VMs and a number of different browser versions.
- Windows 2000: IE5, Firefox 1.5, AOL 9.0
- Windows XP: IE6, Firefox 1.5, AOL 9.0
- Windows Vista: IE7, Firefox 2, AOL 9.1
All details for logging in are on fusion
External Links
Browser Resolution
1024px resolution
- Fold estimated at 570px.
- Optimal width: 960px - Has comfortable padding on both sides, is divisible by many numbers, and also plays well with IAB ad standard widths
- Larger width: 970px - Still has some padding on both sides in most browsers. The math plays well with the Golden Ratio
- Maximum width: 996px - Without incurring any horizontal scrollbars in the major browsers. Based on the research here the maximum is 1003 px wide if you don't want a horizontal scrollbar.
Current stats on window sizes
System resolution is not, however, the same as browser size
Cross-Browser Performance Strategy
There are two major truths when it comes to in-browser experience:
- Both we and the client want the most responsive experience possible.
- Everything added to the page slows it down.
So with these two facts of life, what steps do we need to take so everyone is happy?
Create success metrics with the client
These should be customized to your client and project and done before the wireframing phase. These goals should be reasonable from a technical POV, as well as testable.
Some goals that would be appropriate:
- The slowest browser supported must go from an empty cache to fully loaded and initialized within 10 seconds.
- Hover states (and other ‘instant' changes) should respond within 300ms.
- Animations should appear smooth, with jumpiness occurring < 15% of the time (across all browsers).
For load-time based goals, it's important to define who's computer and connection this must be done on (e.g. the clients). Additionally, the goal may be defined for multiple pages, for example: the two most popular landing pages (e.g. homepage and support).
If the client has more wants more aggressive goals than are reasonable with the intended design, expectations need to be set with visual and interactive design to keep things more minimal.
Communicating the performance impact during design phase
Internally
During IA, IxD, and visual design, it is the interface developer's role to communicate the performance impact of interactive features or certain visual techniques on the target browsers. Give the designers constraints: "If we're using Cufon, we cannot have more than 10 elements of custom font per page."
Externally
Expectations need to be set that all browsers will not have the same experience. They won't perform as well as eachother, nor may it make sense to have feature parity.
It may be sensible to drop a few features from the IE6 and IE7 experience. Features that could be considered to be dropped are: shadows, transitions, rounded corners, opacity, gradients.
When communicating the impact of something:
- Clarify the impact with as much detail as possible: "it will hurt page load" vs "it will add 2 seconds to page load in IE"
- Provide a quick POC (proof of concept) if it's reasonable: "This similar-looking page without siFR loads in 4 seconds, with siFR it loads in 8 and has a delay to show during scrolling"
Develop according to best practices
Choose libraries and plugins that are performance optimized. Make wise architecture decisions based on performance goals. Also minimize DOM manipulation when possible, and write styles to avoid visual changes to the page as it loads and initializes.
Measure performance during QA
QA teams should also prioritize performance related tickets alongside visual, functional, and usability issues. Developers and QA should determine how that priority will be assigned.
During QA, the success metrics should be tested regularly.
Tools to test with
When performance goals aren't met, there are three options:
- Redevelop the code - profile, discover bottlenecks, refactor code, optimize to target faster execution in the browser
- Drop the feature - turn it off for slower browsers only
- Redesign approach of the UI - perhaps the design could use a tweak which would bypass the issue entirely
With this approach, we think all parties have a better chance of having aligned expectations heading in as well as a more sensible workflow in dealing with performance challenges.
Appendices
Appendix A: Validators
Appendix B: Tools
Code Editors
-
Aptana
-
Aptana Studio is a powerful, free and open source Ajax development environment which runs stand-alone or within Eclipse. Aptana Studio offers tooling for Ajax including HTML, CSS, DOM, and JavaScript editing and debugging, plus support via additional free plugins for PHP, Ruby on Rails, Adobe AIR, Apple iPhone development. It also features full SVN repository integration for committing, branching, tagging, merging and repository browsing. Aptana
-
Geany
-
Geany is a text editor using the GTK2 toolkit with basic features of an integrated development environment. It was developed to provide a small and fast IDE, which has only a few dependencies from other packages. It supports many filetypes and has some nice features. Geany
-
Notepad ++
-
Notepad++ is a free (free as in "free speech", but also as in "free beer") source code editor and Notepad replacement, which supports several programming languages, running under the MS Windows environment. Notepad ++
-
e TextEditor
-
E is a new text editor for Windows, with powerful editing features and quite a few unique abilities. It makes manipulating text fast and easy, and lets you focus on your writing by automating all the manual work. You can extend it in any language, and by supporting TextMate bundles, it allows you to tap into a huge and active community. e TextEditor
-
Edit Plus
-
EditPlus is a text editor, HTML editor and programmers editor for Windows. While it can serve as a good Notepad replacement, it also offers many powerful features for Web page authors and programmers. EditPlus
-
Homesite
-
HomeSite 5.5 provides a lean, code-only editor for web development. Advanced coding features enable you to instantly create and modify HTML, CFML, JSP, and XHTML tags, while enhanced productivity tools allow you to validate, reuse, navigate, and format code more easily. Configure Macromedia HomeSite to fit your needs by extending its functionality and customizing the interface. Homesite
Firefox Plugins
-
FireFTP
-
FireFTP is a free, secure, cross-platform FTP client for Mozilla Firefox which provides easy and intuitive access to FTP servers. FireFTP
-
Firebug
-
Firebug integrates with Firefox to put a wealth of development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page. Firebug
-
Greasemonkey
-
Allows you to customize the way a webpage displays using small bits of JavaScript. GreaseMonkey
-
Web Developer Toolbar
-
Adds a menu and a toolbar with various web developer tools. Web Developer Toolbar
-
JSView
-
Adds an item in the status bar that displays all external JavaScript and CSS files loaded on a given page. Allows you to click on and view the files and things like their URLs. Great way to pull file URLs to put into Charles for remote debugging. JSView
-
Live HTTP headers
-
When running, captures all HTTP traffic from the browser, which enables you to see what files are being requested as well as information about the requests and server responses. Live HTTP Headers
-
Quick Locale Switcher
-
A tremendous help when doing internationalization, Quick Locale Switcher allows you to change the locale sent along in the browser's user-agent HTTP header, telling servers to display content for you in other locales.
-
Screengrab
-
Screengrab sits in the Firefox status bar, allowing you to capture and copy or save screen shots of everything from selections of a web page to the entire page, even parts displayed "below the fold." Screengrab
-
Total Validator
-
Enables one-click access to sending your page through a markup validator. No better way to quickly check for missing or mismatched tags! Also available as a standalone application. Total Validator
Charles Proxy
Charles watches all requests and can tell you a lot of information about them. Also supremely useful is Map Local which lets you use a local file in place of a given URL (good for replacing a minified js with a full one). License info located on our wiki
Firefox Plugin Repository
These plugins and more are available in single install in the Isobar iDev Plugin Repository. Versions are
available for Firefox 3.5 and Firefox 3.6.
The repository is a single .xpi and includes:
- Charles Autoconfiguration - Plugin allowing Charles to proxy Firefox traffic
- CLEO and FEBE - Make your own extension packages!
- ColorZilla color picker
- Firebug
- Firecookie - Cookie manager for Firebug.
- Firefinder for Firebug - CSS selector / XPath query engine
- Firefocus - Tracks which HTMLElements have focus in Firebug. Note: because this plugin impacts performance, it is recommended that you disable it until you really need it!
- FireFTP
- Image Zoom
- JSView (Firefox 3.5 only)
- Live HTTP Headers
- MeasureIt screen ruler
- Quick Locale Switcher
- Screengrab
- SenSEO - basic keyword analyzer
- Total Validator
- Web Developer
- YSlow
IE Plugins
CompanionJS, DebugBar, IE8 Dev tools
IE Developer Toolbar:
The Microsoft Internet Explorer Developer Toolbar provides a variety of tools for quickly creating, understanding, and troubleshooting Web pages. IE Developer Toolbar
Tutorials & Tools:
Icons
Appendix C: Resources
Revision History
Authors: Paul Irish, Nick Cooley, Adam McIntyre, Rob Larsen, Joel Oliviera, Ben Menoza and Nathan Smith.