30
Best practices for cross-browser compatibility of Drupal website Vadim Mirgorod

DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

Best practices for cross-browser compatibility of Drupal website

Vadim Mirgorod

Page 2: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

2

Usage share of web browsers: January 2011

Internet Explorer (43.8%) Mozilla Firefox (29.7%) Google Chrome (13.0%) Safari (6.1%) Opera (2.2%) Mobile browsers (4.3%)

Source: http://en.wikipedia.org/wiki/Usage_share_of_web_browsers

Page 3: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

3

Top 12 browsers by StatCounter: January 2011

Source: http://gs.statcounter.com/#browser_version-ww-monthly-201001-201101-bar

← IE 7.0← IE 6.0

Page 4: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

4

Drupal theming observations

• Modern browsers• IE 6 and IE 7• Opera• Fonts• Drupal core CSS• Fixed-width layout

Page 5: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

5

Drupal theming suggestions

• float: left instead of display: inline-block

• PNG for transparent background• Rounded Corners

– border-radius for Webkit and Opera– -moz-border-radius for Mozilla– Rounded Corners module for IE

• Web safe fonts• Specific styles for different browsers

Page 6: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

6

Conditional Comments

<!--[if IE 6]>

Special instructions for IE 6 here

<![endif]-->

Image by Brenda Starr

Page 7: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

7

Conditional Comments (IE)

Should start with

<!--[if IE]>

<!--[if IE 5]>

<!--[if IE 5.0]>

<!--[if gte IE 5]>

<!--[if lt IE 6]>

<!--[if lte IE 5.5]>

<!--[if gt IE 6]>

gt – greater thenlt – lower thengte – greater then or equal tolte – lower then or equal to

Page 8: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

8

Conditional Comments(non-IE)

<!--[if !IE]><!-->

<h1>You are NOT using Internet Explorer</h1>

<!--<![endif]-->

<!--[if IE 6]><!-->

<h1>You are using EITHER IE 6 OR a non-IE</h1>

<!--<![endif]-->

<!--[if IE 6]>Instructions for IE6<!-->

Instructions for IE6 and non-IE

<!--<![endif]-->

Page 9: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

9

Conditional Comments in DrupalConditional Comments in Drupal

3 Paths3 PathsImage by Image by Ryan B Schultz

Page 10: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

10

Padawan Path:sites/all/themes/your_theme/page.tpl.php

Page 11: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

11

Jedi Knight Path:sites/all/themes/your_theme/template.php

Page 12: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

12

Jedi Master Path (D7):sites/all/themes/your_theme/template.php

See drupal_pre_render_conditional_comments()

Page 13: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

13

CSS HacksCSS Hacks

Image by Image by Lincolnian

Page 14: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

14

CSS Hacks/Filters

A hack is a method of exploiting the way a web browser parses CSS rules, to control the styles a webpage receives.

‘Control’ includes the ability to hide or change rules based on the browser type and/or version.

Page 15: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

15

CSS Hacks Examples

Page 16: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

16

JavaScript Trick

Image by Image by Jenn and Tony

Page 17: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

17

JavaScript Tricktheme.js:

opera.css:

Page 18: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

18

Useful modules for cross- browser compatibility

Page 19: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

19

Conditional Stylesheets(D6 and D7)

you_theme.info:

; Set the conditional stylesheets that are processed by IE.

stylesheets-conditional[lt IE 7][all][] = ie6-and-below.css

stylesheets-conditional[IE 9][all][] = ie9.css

stylesheets-conditional[IE][print][] = ie-print.css

http://drupal.org/project/conditional_styles

Page 20: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

20

Conditional CSS Integration(D6)

http://drupal.org/project/conditional_css

Page 21: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

21

IE CSS Optimizer(D6)

Solves the Internet Explorer limitation of loading not more than 31 CSS files per HTML page. Provides flexible settings for CSS optimization.

http://drupal.org/project/ie_css_optimizer

Page 22: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

22

IE Unlimited CSS Loader(D6)

Does almost the same as IE CSS Optimizer does with a small differences. Have no settings.

Allows for up to 9 additional stylesheets explicitly embedded in page.tpl.php, that the module logic does not know about.

http://drupal.org/project/unlimited_css

Page 23: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

23

Testing Tools

Image by tronixstuff

Page 24: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

24

Browser compatibility testing software

• Compatibility mode in IE8• IE Tester: http://ietester.com/• MultiplesIEs: http://tredosoft.com/multiple_ie• Multi-Safari:

http://michelf.com/projects/multi-safari/• Mozilla Firefox Collection:

http://mozilla-firefox-collection.en.softonic.com/

Page 25: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

25

IE Tester

Page 26: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

26

Web Services

• http://browserlab.adobe.com/

• http://ipinfo.info/netrenderer/• http://www.webdevlab.com/• Many others

Page 27: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

27

HTML/CSS Validators

Web services:http://validator.w3.org/http://jigsaw.w3.org/css-validator/

Firefox addons:http://users.skynet.be/mgueury/mozilla/

https://addons.mozilla.org/en-US/firefox/addon/css-validator/

Page 28: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

28

Virtual Machines

Virtual Machine emulates behavior of PC running Guest OS. VM is executed on top of Host OS or Hypervisor. Several instances of Virtual Machine could work simultaneously.

Software: Oracle VirtualBox, VMWare, Microsoft VirtualPC, etc...

Page 29: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

29

Browser Tools

• Firebug for Firefox• Firebug Light• Internet Explorer Developer Tools• Webkit Web Inspector

Page 30: DrupalCon Chicago - Best practices for cross-browser compatibility of Drupal website

What did you think?Locate this session on the DCC website:http://chicago2011.drupal.org/sessions

Click the “Take the Survey” link.

Thanks!