SlideShare a Scribd company logo
Custom select element rage Or, how I learned to stop worrying and love the DOM Ray Brooks August 2011
Custom select element rage
INPUTS! Y U NO STYLE? INPUT, BUTTON, TEXTAREA, SELECT Levels of CSS support for these vary It’s fiddly It’s boring You achieve inconsistent results Multipart file inputs are a unique form (sic) of EVIL But worst of all… Microsoft’s TRIDENT rendering engine (IE 6,7,8) uses O/S controls as opposed to browser objects and the two are different beasts. C++ doesn’t understand CSS. WE CAN’T STYLE THEM AT ALL
A wild solution appears! Felix Nagel has forked & extended Filament’s jQuery UI His solution requires jQuery & Javascript It’s styleable It’s accessible It supports ARIA Seems to work well even in IE6+! Check out the repo: https://github.com/fnagel/jquery-ui/ *le jQuery UI SelectMenu
Felix Nagel’s fork of jQuery UI, I choose you!
LBi uses Very Big Form
It’s not very effective! Number of SELECT elements Load time (ms) ONE SELECT ELEMENT TAKES ~800ms TO RENDER IN IE8 problem?
OH NOES! Complex elements such as SELECT have been simulated in full using much markup and many event bindings The SELECT replacement code in particular makes many DOM accesses via jQuery, which is slow It’s not such a big problem with browsers that can optimise Javascript, however… This is a very big page, and Not all browsers can optimise Javascript OH, SWEET IRONY! They’re also the browsers we are most interested in supporting!
The Challenge Client’s page load time is 90s in IE8, 170s in IE7 + IE6! Reduce page load time to under 10 seconds for all level 1 and 2 browsers (Chrome 10+, FF 3+, IE7+, Safari 3+)
 
Flyweight pattern “ The intent of this pattern is to use sharing to support a large number of objects that have part of their internal state in common where the other part of state can vary.” http://www.oodesign.com/flyweight-pattern.html
Our solution Delay as much as possible until after page load completes Construct only one anchor to replace one SELECT element Share one drop down menu between all SELECT elements Construct markup as strings, which is fast Convert strings to objects as late as possible Cache SELECT values in memory for fast retrieval Bind events only to top level elements and use bubbling Optimise all loops For speed, use as much pure Javascript as possible
Notwithstanding… Behaviourally identical to SELECT Accessible Semantic Graceful And of course…
 
Right, this shouldn’t take me very long
 
Hm. I obviously need to get better at estimating this kind of shit
LET’S SEE SOME REAL WORLD PERFORMANCE TESTING, THEN
IE6 XPSP2 VM 60 SELECTS 312ms ~5ms/SELECT
IE8 XPSP2 VM 60 SELECTS 219ms <4ms/SELECT
Chrome 13 native 60 SELECTS 97ms <2ms/SELECT
HALLELUJAH
flyweight-jquery-custom-select Lightweight Extremely fast Semantic markup Fully customisable keyboard navigation Fully customisable class names Intelligent typeahead  Option group support Enable/disable Graceful destroy, original select maintains state Supports CSS3 Supports PIE.htc for IE6/7/8 CSS3 emulation Toggle hide first option element (for Please Select, etc) Binds to original select change event Auto scroll Only 8KB compressed Works in all tested major browsers FF 3.6/5.1, Chrome 11/12, Safari 5, IE 6/7/8
Examples of usage default $(&quot;select&quot;).flyweightCustomSelect(); with options $(&quot;select&quot;).flyweightCustomSelect( { optionfilter:'option,optgroup', pleaseselect:true } );
https://github.com/rayui/flyweight-jquery-custom-select And that’s why we can now begin to use custom selects on very big forms Thanks for listening!

More Related Content

PPTX
Christmas Trees Made with HTML CSS and JS
PDF
The Onion
PDF
jQuery Keynote - Fall 2010
PPTX
HTTP 2.0 - Web Unleashed 2015
PDF
All for Web development
PPTX
Power to the People: Manipulating SharePoint with Client-Side JavaScript
PDF
PrairieDevCon 2014 - Web Doesn't Mean Slow
DOCX
Christmas Trees Made with HTML CSS and JS
The Onion
jQuery Keynote - Fall 2010
HTTP 2.0 - Web Unleashed 2015
All for Web development
Power to the People: Manipulating SharePoint with Client-Side JavaScript
PrairieDevCon 2014 - Web Doesn't Mean Slow

What's hot (20)

PDF
Why Use Rails by Dr Nic
PPTX
Misused figures of dev ops
PPTX
Frontend architecture design for large(r) team final
PDF
Bringing The Sexy Back To WebWorkers
PPTX
jQuery Conference 2012 keynote
PDF
Scaling Selenium
DOCX
jQuery Code Testing
PPT
Js unit testing
PDF
WordCamp SF 2011: Debugging in WordPress
PDF
jQuery Conference Toronto
KEY
SGCE 2012 Lightning Talk-Single Page Interface
PDF
Lesson learned from 3 years with hybrid apps
PPTX
Heuristics to scale your framework
PPTX
Javascript Frameworks Comparison
PPTX
BlackBerry 10 Browser
PDF
jQuery Chicago 2014 - Next-generation JavaScript Testing
KEY
Rapid Testing, Rapid Development
PPT
The Realtime Web: Stateful and Programmable
PPT
Why Java
PPTX
Claim Academy Intro to Programming
Why Use Rails by Dr Nic
Misused figures of dev ops
Frontend architecture design for large(r) team final
Bringing The Sexy Back To WebWorkers
jQuery Conference 2012 keynote
Scaling Selenium
jQuery Code Testing
Js unit testing
WordCamp SF 2011: Debugging in WordPress
jQuery Conference Toronto
SGCE 2012 Lightning Talk-Single Page Interface
Lesson learned from 3 years with hybrid apps
Heuristics to scale your framework
Javascript Frameworks Comparison
BlackBerry 10 Browser
jQuery Chicago 2014 - Next-generation JavaScript Testing
Rapid Testing, Rapid Development
The Realtime Web: Stateful and Programmable
Why Java
Claim Academy Intro to Programming
Ad

Viewers also liked (13)

PPT
Flyweight pattern
PPT
Facade pattern
PPTX
Design pattern builder 20131115
PPTX
Design Patterns - 03 Composite and Flyweight Pattern
PPSX
Proxy design pattern
PDF
Builder Design Pattern (Generic Construction -Different Representation)
PPTX
Flyweight Design Pattern
PDF
Proxy design pattern (Class Ambassador)
PPTX
Proxy Design Pattern
PPT
Builder pattern
PPTX
Design pattern - Facade Pattern
PPTX
Gof design patterns
PPTX
Facade Pattern
Flyweight pattern
Facade pattern
Design pattern builder 20131115
Design Patterns - 03 Composite and Flyweight Pattern
Proxy design pattern
Builder Design Pattern (Generic Construction -Different Representation)
Flyweight Design Pattern
Proxy design pattern (Class Ambassador)
Proxy Design Pattern
Builder pattern
Design pattern - Facade Pattern
Gof design patterns
Facade Pattern
Ad

Similar to Flyweight jquery select_presentation (20)

PPTX
Lessons Learned: Migrating Tests to Selenium v2
KEY
Advanced jQuery
PDF
Jquery Cookbook Solutions Examples For Jquery Developers Lindley
PDF
Jquery enlightenment
PPT
Kick start with j query
PDF
Jquery In Action Second Edition 2nd Ed Bear Bibeault Yehuda Katz
PPT
J query b_dotnet_ug_meet_12_may_2012
KEY
The HTML select tag styling challenge
KEY
jQuery Anti-Patterns for Performance
PPT
J query module1
PPT
jQuery for beginners
PPTX
Jquery fundamentals
PPTX
jQuery Performance Tips and Tricks
PPTX
Iniciando com jquery
PPTX
JQuery
KEY
jQuery Anti-Patterns for Performance & Compression
PDF
JQuery do dia-a-dia Gustavo Dutra
PDF
jQuery - Introdução
PDF
J query fundamentals
PDF
Introduction to jQuery
Lessons Learned: Migrating Tests to Selenium v2
Advanced jQuery
Jquery Cookbook Solutions Examples For Jquery Developers Lindley
Jquery enlightenment
Kick start with j query
Jquery In Action Second Edition 2nd Ed Bear Bibeault Yehuda Katz
J query b_dotnet_ug_meet_12_may_2012
The HTML select tag styling challenge
jQuery Anti-Patterns for Performance
J query module1
jQuery for beginners
Jquery fundamentals
jQuery Performance Tips and Tricks
Iniciando com jquery
JQuery
jQuery Anti-Patterns for Performance & Compression
JQuery do dia-a-dia Gustavo Dutra
jQuery - Introdução
J query fundamentals
Introduction to jQuery

Recently uploaded (20)

PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPT
Teaching material agriculture food technology
PDF
Assigned Numbers - 2025 - Bluetooth® Document
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Machine Learning_overview_presentation.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Encapsulation theory and applications.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
A Presentation on Artificial Intelligence
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
cuic standard and advanced reporting.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Teaching material agriculture food technology
Assigned Numbers - 2025 - Bluetooth® Document
The AUB Centre for AI in Media Proposal.docx
A comparative analysis of optical character recognition models for extracting...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Machine Learning_overview_presentation.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Big Data Technologies - Introduction.pptx
Encapsulation_ Review paper, used for researhc scholars
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Encapsulation theory and applications.pdf
NewMind AI Weekly Chronicles - August'25-Week II
A Presentation on Artificial Intelligence
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Review of recent advances in non-invasive hemoglobin estimation
cuic standard and advanced reporting.pdf
Electronic commerce courselecture one. Pdf
MIND Revenue Release Quarter 2 2025 Press Release
20250228 LYD VKU AI Blended-Learning.pptx

Flyweight jquery select_presentation

  • 1. Custom select element rage Or, how I learned to stop worrying and love the DOM Ray Brooks August 2011
  • 3. INPUTS! Y U NO STYLE? INPUT, BUTTON, TEXTAREA, SELECT Levels of CSS support for these vary It’s fiddly It’s boring You achieve inconsistent results Multipart file inputs are a unique form (sic) of EVIL But worst of all… Microsoft’s TRIDENT rendering engine (IE 6,7,8) uses O/S controls as opposed to browser objects and the two are different beasts. C++ doesn’t understand CSS. WE CAN’T STYLE THEM AT ALL
  • 4. A wild solution appears! Felix Nagel has forked & extended Filament’s jQuery UI His solution requires jQuery & Javascript It’s styleable It’s accessible It supports ARIA Seems to work well even in IE6+! Check out the repo: https://github.com/fnagel/jquery-ui/ *le jQuery UI SelectMenu
  • 5. Felix Nagel’s fork of jQuery UI, I choose you!
  • 6. LBi uses Very Big Form
  • 7. It’s not very effective! Number of SELECT elements Load time (ms) ONE SELECT ELEMENT TAKES ~800ms TO RENDER IN IE8 problem?
  • 8. OH NOES! Complex elements such as SELECT have been simulated in full using much markup and many event bindings The SELECT replacement code in particular makes many DOM accesses via jQuery, which is slow It’s not such a big problem with browsers that can optimise Javascript, however… This is a very big page, and Not all browsers can optimise Javascript OH, SWEET IRONY! They’re also the browsers we are most interested in supporting!
  • 9. The Challenge Client’s page load time is 90s in IE8, 170s in IE7 + IE6! Reduce page load time to under 10 seconds for all level 1 and 2 browsers (Chrome 10+, FF 3+, IE7+, Safari 3+)
  • 10.  
  • 11. Flyweight pattern “ The intent of this pattern is to use sharing to support a large number of objects that have part of their internal state in common where the other part of state can vary.” http://www.oodesign.com/flyweight-pattern.html
  • 12. Our solution Delay as much as possible until after page load completes Construct only one anchor to replace one SELECT element Share one drop down menu between all SELECT elements Construct markup as strings, which is fast Convert strings to objects as late as possible Cache SELECT values in memory for fast retrieval Bind events only to top level elements and use bubbling Optimise all loops For speed, use as much pure Javascript as possible
  • 13. Notwithstanding… Behaviourally identical to SELECT Accessible Semantic Graceful And of course…
  • 14.  
  • 15. Right, this shouldn’t take me very long
  • 16.  
  • 17. Hm. I obviously need to get better at estimating this kind of shit
  • 18. LET’S SEE SOME REAL WORLD PERFORMANCE TESTING, THEN
  • 19. IE6 XPSP2 VM 60 SELECTS 312ms ~5ms/SELECT
  • 20. IE8 XPSP2 VM 60 SELECTS 219ms <4ms/SELECT
  • 21. Chrome 13 native 60 SELECTS 97ms <2ms/SELECT
  • 23. flyweight-jquery-custom-select Lightweight Extremely fast Semantic markup Fully customisable keyboard navigation Fully customisable class names Intelligent typeahead Option group support Enable/disable Graceful destroy, original select maintains state Supports CSS3 Supports PIE.htc for IE6/7/8 CSS3 emulation Toggle hide first option element (for Please Select, etc) Binds to original select change event Auto scroll Only 8KB compressed Works in all tested major browsers FF 3.6/5.1, Chrome 11/12, Safari 5, IE 6/7/8
  • 24. Examples of usage default $(&quot;select&quot;).flyweightCustomSelect(); with options $(&quot;select&quot;).flyweightCustomSelect( { optionfilter:'option,optgroup', pleaseselect:true } );
  • 25. https://github.com/rayui/flyweight-jquery-custom-select And that’s why we can now begin to use custom selects on very big forms Thanks for listening!

Editor's Notes

  • #6: Client: Compare the Market