<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.forum.nokia.com/piazza/wiki/skins/common/feed.css?878"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title>Forum Nokia Wiki - Recent changes [en]</title>
		<link>http://wiki.forum.nokia.com/index.php/Special:Newestpages</link>
		<description>Track the most recent changes to the wiki in this feed.</description>
		<language>en</language>
		<generator>MediaWiki 1.15.1</generator>
		<lastBuildDate>Thu, 26 Nov 2009 06:12:04 GMT</lastBuildDate>
		<item>
			<title>JavaScript Performance Best Practices</title>
			<link>http://wiki.forum.nokia.com/index.php/JavaScript_Performance_Best_Practices</link>
			<description>&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;table id=&quot;toc&quot; class=&quot;toc&quot; summary=&quot;Contents&quot;&gt;&lt;tr&gt;&lt;td&gt;&lt;div id=&quot;toctitle&quot;&gt;&lt;h2&gt;Contents&lt;/h2&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-1&quot;&gt;&lt;a href=&quot;#JavaScript_Performance_Best_Practices&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;JavaScript Performance Best Practices&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-2&quot;&gt;&lt;a href=&quot;#Overview&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Overview&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot;&gt;&lt;a href=&quot;#Core_JavaScript_pitfalls&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Core JavaScript pitfalls&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Avoid_using_eval_or_the_Function_constructor&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.2.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Avoid using eval or the Function constructor&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Avoid_using_with&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.2.2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Avoid using with&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Don.27t_use_try-catch-finally_inside_performance-critical_functions&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.2.3&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Don't use try-catch-finally inside performance-critical functions&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Avoid_using_global_variables&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.2.4&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Avoid using global variables&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Avoid_for-in_in_performance-critical_functions&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.2.5&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Avoid for-in in performance-critical functions&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Use_strings_accumulator-style&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.2.6&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Use strings accumulator-style&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Primitive_operations_can_be_faster_than_function_calls&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.2.7&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Primitive operations can be faster than function calls&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Pass_functions.2C_not_strings.2C_to_setTimeout.28.29_and_setInterval.28.29&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.2.8&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Pass functions, not strings, to setTimeout() and setInterval()&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Store_local_references_to_out-of-scope_variables&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.2.9&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Store local references to out-of-scope variables&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot;&gt;&lt;a href=&quot;#Tips_for_better_loading_performance&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.3&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Tips for better loading performance&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Load_scripts_without_blocking_for_faster_startup_and_to_show_a_splash_screen&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.3.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Load scripts without blocking for faster startup and to show a splash screen&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Add_an_Expires_or_a_Cache-Control_HTTP_header&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.3.2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Add an Expires or a Cache-Control HTTP header&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Gzip_JavaScript_and_CSS_resources&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.3.3&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Gzip JavaScript and CSS resources&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Use_YUI_Compressor_or_JSMin_to_compress_the_code&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.3.4&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Use YUI Compressor or JSMin to compress the code&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Minimize_the_number_and_size_of_resources&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.3.5&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Minimize the number and size of resources&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Load_scripts_without_blocking_parallel_downloads&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.3.6&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Load scripts without blocking parallel downloads&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Couple_asynchronous_scripts&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.3.7&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Couple asynchronous scripts&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Move_inline_scripts_above_stylesheets&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.3.8&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Move inline scripts above stylesheets&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Use_iframes_sparingly&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.3.9&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Use iframes sparingly&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot;&gt;&lt;a href=&quot;#Document_Object_Model_.28DOM.29_obscurities&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.4&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Document Object Model (DOM) obscurities&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Minimize_the_size_of_the_DOM&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.4.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Minimize the size of the DOM&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Use_document_fragment_templates_for_re-usability&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.4.2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Use document fragment templates for re-usability&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Minimize_the_number_of_reflows_and_repaints&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.4.3&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Minimize the number of reflows and repaints&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-4&quot;&gt;&lt;a href=&quot;#Use_createDocumentFragment.28.29&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.4.3.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Use createDocumentFragment()&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-4&quot;&gt;&lt;a href=&quot;#Use_cloneNode.28.29&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.4.3.2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Use cloneNode()&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-4&quot;&gt;&lt;a href=&quot;#Use_HTML_templates_and_innerHTML&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.4.3.3&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Use HTML templates and innerHTML&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-4&quot;&gt;&lt;a href=&quot;#Modify_an_invisible_element&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.4.3.4&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Modify an invisible element&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-4&quot;&gt;&lt;a href=&quot;#Minimize_the_use_of_operations_determining_the_dimensions_or_location_of_elements&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.4.3.5&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Minimize the use of operations determining the dimensions or location of elements&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-4&quot;&gt;&lt;a href=&quot;#Make_multiple_predefined_style_changes_at_once_using_className&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.4.3.6&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Make multiple predefined style changes at once using className&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-4&quot;&gt;&lt;a href=&quot;#Make_multiple_dynamic_style_changes_at_once_using_setAttribute&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.4.3.7&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Make multiple dynamic style changes at once using setAttribute&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-4&quot;&gt;&lt;a href=&quot;#CSS_class_name_vs._style_property_changing&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.4.3.8&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;CSS class name vs. style property changing&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Avoid_traversing_large_number_of_nodes&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.4.4&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Avoid traversing large number of nodes&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Avoid_modifications_while_traversing&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.4.5&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Avoid modifications while traversing&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Cache_DOM_values_into_variables&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.4.6&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Cache DOM values into variables&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Remove_references_to_documents_that_have_been_closed&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.4.7&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Remove references to documents that have been closed&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot;&gt;&lt;a href=&quot;#Object-Oriented_JavaScript&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.5&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Object-Oriented JavaScript&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Consider_alternative_inheritance_mechanisms&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.5.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Consider alternative inheritance mechanisms&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot;&gt;&lt;a href=&quot;#Client-server_communication&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.6&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Client-server communication&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Set_timeouts_to_XMLHttpRequests&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.6.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Set timeouts to XMLHttpRequests&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Consider_using_a_custom_data_exchange_format_for_large_datasets.2C_as_an_alternative_to_XML_and_JSON&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.6.2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Consider using a custom data exchange format for large datasets, as an alternative to XML and JSON&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot;&gt;&lt;a href=&quot;#Animations&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.7&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Animations&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Use_animations_modestly&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.7.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Use animations modestly&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Use_scrollTo.28.29_to_animate_scrolling&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.7.2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Use scrollTo() to animate scrolling&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Absolutely_or_fixed_position_animated_elements&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.7.3&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Absolutely or fixed position animated elements&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Use_one_timer_to_animate_multiple_elements_at_the_same_time&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.7.4&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Use one timer to animate multiple elements at the same time&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Trade_animation_smoothness_for_speed&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.7.5&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Trade animation smoothness for speed&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot;&gt;&lt;a href=&quot;#Events&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.8&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Events&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Use_event_delegation&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.8.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Use event delegation&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Throttle_event_handlers_which_fire_excessively&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.8.2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Throttle event handlers which fire excessively&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Escaping_the_JavaScript_call_stack_with_setTimeout&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.8.3&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Escaping the JavaScript call stack with setTimeout&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot;&gt;&lt;a href=&quot;#Styling&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.9&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Styling&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Optimize_CSS&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.9.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Optimize CSS&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-4&quot;&gt;&lt;a href=&quot;#Change_CSS_classes_near_the_edges_of_the_DOM_tree&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.9.1.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Change CSS classes near the edges of the DOM tree&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-4&quot;&gt;&lt;a href=&quot;#Avoid_tables_for_layout_or_use_table-layout:_fixed&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.9.1.2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Avoid tables for layout or use table-layout: fixed&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Optimize_images&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.9.2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Optimize images&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot;&gt;&lt;a href=&quot;#S60_specifics&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.10&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;S60 specifics&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Styling_2&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.10.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Styling&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-4&quot;&gt;&lt;a href=&quot;#Remove_borders_around_focusable_elements&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.10.1.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Remove borders around focusable elements&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-4&quot;&gt;&lt;a href=&quot;#Fix_focus_problems_in_tabbed_navigation_mode&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.10.1.2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Fix focus problems in tabbed navigation mode&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-4&quot;&gt;&lt;a href=&quot;#Prevent_elements_losing_focus_in_tabbed_navigation_mode&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.10.1.3&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Prevent elements losing focus in tabbed navigation mode&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-4&quot;&gt;&lt;a href=&quot;#Allow_animated_gif_images_to_animate_after_being_hidden&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.10.1.4&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Allow animated gif images to animate after being hidden&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Home_Screen_Widgets&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.10.2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Home Screen Widgets&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Misc&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.10.3&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Misc&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-4&quot;&gt;&lt;a href=&quot;#Avoid_background-repeat_if_the_background-image_is_small_relative_to_its_containing_element&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.10.3.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Avoid background-repeat if the background-image is small relative to its containing element&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#jQuery_Issues_and_Workarounds&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.10.4&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;jQuery Issues and Workarounds&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot;&gt;&lt;a href=&quot;#jQuery-specifics&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.11&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;jQuery-specifics&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Minimize_the_use_of_slow_jQuery_methods&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.11.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Minimize the use of slow jQuery methods&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Optimize_selectors&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.11.2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Optimize selectors&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Consider_alternatives_to_jQuery.each.28.29&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.11.3&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Consider alternatives to jQuery.each()&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot;&gt;&lt;a href=&quot;#References&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.12&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;References&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Generic&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.12.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Generic&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#jQuery-specific&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1.12.2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;jQuery-specific&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;script type=&quot;text/javascript&quot;&gt; if (window.showTocToggle) { var tocShowText = &quot;show&quot;; var tocHideText = &quot;hide&quot;; showTocToggle(); } &lt;/script&gt;
&lt;a name=&quot;JavaScript_Performance_Best_Practices&quot; id=&quot;JavaScript_Performance_Best_Practices&quot;&gt;&lt;/a&gt;&lt;h1&gt; &lt;span class=&quot;mw-headline&quot;&gt;JavaScript Performance Best Practices&lt;/span&gt;&lt;/h1&gt;
&lt;a name=&quot;Overview&quot; id=&quot;Overview&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Overview&lt;/span&gt;&lt;/h2&gt;
&lt;ul&gt;&lt;li&gt; Source: &lt;a href=&quot;http://dev.opera.com/articles/view/efficient-javascript/?page=2&quot; class=&quot;external text&quot; title=&quot;http://dev.opera.com/articles/view/efficient-javascript/?page=2&quot; rel=&quot;nofollow&quot;&gt;Efficient JavaScript - ECMAScript&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;First understand the big picture and the major component of the stack affecting the performance. It is of utmost importance to understand what can and can not be optimized in JavaScript without touching the browser codebase. A good starting point for this study is to first take a look at the &lt;a href=&quot;http://ejohn.org/blog/javascript-performance-stack/&quot; class=&quot;external text&quot; title=&quot;http://ejohn.org/blog/javascript-performance-stack/&quot; rel=&quot;nofollow&quot;&gt;JavaScript Performance Stack&lt;/a&gt; (depicted in the figure). 
&lt;/p&gt;&lt;p&gt;Pick your battles. It is generally a good approach to first optimize those parts which give you the biggest improvements. 
&lt;/p&gt;&lt;p&gt;There are many interrelated components that play an instrumental role in the real-life web application performance such as those responsible for layouting, rendering, parsing HTML, marshaling, DOM, CSS formatting, JavaScript -- as you see, JavaScript is only one part of the performance equation. 
&lt;/p&gt;&lt;p&gt;The most expensive operations tend to be reflowing the layout and repainting. 
Although you as a JavaScript developer can not optimize browser layout or painting algorithms you can still implicitly affect the performance of these expensive operations by trying to avoid triggering there expensive operations unnecessarily. 
A real-life example of IE8 tells us that layout and rendering tasks takes most time on IE8 (see &lt;a href=&quot;http://yuiblog.com/blog/2008/12/23/video-crockford-performance/&quot; class=&quot;external text&quot; title=&quot;http://yuiblog.com/blog/2008/12/23/video-crockford-performance/&quot; rel=&quot;nofollow&quot;&gt;webcast&lt;/a&gt; at -20:00 mins) 
&lt;/p&gt;&lt;p&gt;Below are some examples of common reasons for slow JavaScript performance that you as a JavaScript developer can easily fix and make your web application to perform better instantly:
&lt;/p&gt;
&lt;table border=&quot;1&quot;&gt;
&lt;tr&gt;
&lt;td&gt;DOM access
&lt;/td&gt;&lt;td&gt;Interaction with the DOM is usually slower than normal JavaScript code. Interaction with the DOM is usually inevitable, but try to minimize it. For instance, dynamically creating HTML with strings and setting the innerHTML is usually faster than creating HTML with DOM methods.
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;eval
&lt;/td&gt;&lt;td&gt;Whenever possible, avoid the eval method because significant overhead is involved in script evaluation.
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;with
&lt;/td&gt;&lt;td&gt;Using with statements creates additional scope objects that slow variable access and create ambiguities.
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;for-in loops
&lt;/td&gt;&lt;td&gt;Traverse arrays use the traditional &lt;tt&gt;for (var i=0; i&amp;lt;array.length; i++) &lt;/tt&gt;instead of for-in loops. Unfortunately, most JavaScript environments have a slow implementation of for-in loops.
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;a name=&quot;Core_JavaScript_pitfalls&quot; id=&quot;Core_JavaScript_pitfalls&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Core JavaScript pitfalls&lt;/span&gt;&lt;/h2&gt;
&lt;a name=&quot;Avoid_using_eval_or_the_Function_constructor&quot; id=&quot;Avoid_using_eval_or_the_Function_constructor&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Avoid using eval or the Function constructor&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Using eval or Function constructor are expensive operations as each time they are called script engine must convert source code to executable code. 
&lt;/li&gt;&lt;li&gt;Additionally, using eval the context of the string has to be interpreted at runtime.
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; addMethod&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;object&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; property&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; code&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    object&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;property&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;Function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;code&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;addMethod&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;myObj&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'methodName'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'this.localVar=foo'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; addMethod&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;object&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; property&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; func&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    object&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;property&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; func&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;addMethod&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;myObj&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'methodName'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'this.localVar=foo'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Avoid_using_with&quot; id=&quot;Avoid_using_with&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Avoid using with&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;Although seen as a convenience, with construct introduces an extra scope to search each time variable is referenced and the contents of that scope is not known at compile time. 
&lt;/p&gt;&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;with&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;test.&lt;span style=&quot;color: #660066;&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    foo &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'Value of foo property of object'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    bar &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'Value of bar property of object'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; myObj &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; test.&lt;span style=&quot;color: #660066;&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;myObj.&lt;span style=&quot;color: #660066;&quot;&gt;foo&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'Value of foo property of object'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;myObj.&lt;span style=&quot;color: #660066;&quot;&gt;bar&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'Value of bar property of object'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Don.27t_use_try-catch-finally_inside_performance-critical_functions&quot; id=&quot;Don.27t_use_try-catch-finally_inside_performance-critical_functions&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Don't use try-catch-finally inside performance-critical functions&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;The try-catch-finally construct creates a new variable in the current scope at runtime each time the catch clause is executed where the caught exception object is asigned to a variable. 
&lt;/li&gt;&lt;li&gt;Exception handling should be done at as high level in the script where it does not occur frequently, for example outside a loop. 
&lt;/li&gt;&lt;li&gt;Or if possible, avoid try-catch-finally completely 
&lt;/li&gt;&lt;/ul&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;Slow&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; object &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'foo'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'bar'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; object.&lt;span style=&quot;color: #660066;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;   &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;try&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// do something that throws an exception&lt;/span&gt;&lt;br /&gt;   &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;catch&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// handle exception&lt;/span&gt;&lt;br /&gt;   &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; object &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'foo'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'bar'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;try&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; object.&lt;span style=&quot;color: #660066;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// do something&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;catch&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// handle exception&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Avoid_using_global_variables&quot; id=&quot;Avoid_using_global_variables&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Avoid using global variables&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;If you reference global variables from within function or another scope, scripting engine has to look through the scope to find them. 
&lt;/li&gt;&lt;li&gt;Variable in the global scope persist though the life time of the script, whereas in local scope they are destroyed when the local scope is lost. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; str &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;''&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; globalScope&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;i&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;        str &lt;span style=&quot;color: #339933;&quot;&gt;+=&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// here we reference i and str in global scope which is slow&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;globalScope&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;code&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;Faster&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;br /&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;code javascript&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; localScope&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; str &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;''&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;i&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;        str &lt;span style=&quot;color: #339933;&quot;&gt;+=&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// i and str in local scope which is faster&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;localScope&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Avoid_for-in_in_performance-critical_functions&quot; id=&quot;Avoid_for-in_in_performance-critical_functions&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Avoid for-in in performance-critical functions&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;The for-in loop requires the script engine to build a list of all the enumerable properties and check for duplicates prior the start. 
&lt;/li&gt;&lt;li&gt;If your code inside for loop does not modify the array it iterates pre-compute the length of the array into a variable len inside for loop scope. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; sum &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; i &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;in&lt;/span&gt; arr&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;   sum &lt;span style=&quot;color: #339933;&quot;&gt;+=&lt;/span&gt; arr&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;
Faster:
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; sum &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; 0&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; len &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; arr.&lt;span style=&quot;color: #660066;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; len&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;   sum &lt;span style=&quot;color: #339933;&quot;&gt;+=&lt;/span&gt; arr&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Use_strings_accumulator-style&quot; id=&quot;Use_strings_accumulator-style&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Use strings accumulator-style&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Using + operator a new string is created in memory and the concatenated value is assigned to it. Only after this the result is assigned to a variable. 
&lt;/li&gt;&lt;li&gt;To avoid the intermediate variable for concatenation result, you can directly assign the result using += operator. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;tt&gt;a += 'x' + 'y';&lt;/tt&gt;
&lt;/p&gt;&lt;p&gt;Faster: 
&lt;tt&gt;a += 'x';&lt;/tt&gt;
&lt;tt&gt;a += 'y';&lt;/tt&gt;
&lt;/p&gt;
&lt;a name=&quot;Primitive_operations_can_be_faster_than_function_calls&quot; id=&quot;Primitive_operations_can_be_faster_than_function_calls&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Primitive operations can be faster than function calls &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Consider using alternative primitive operation over function calls in performance critical loops and functions. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; min &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; Math.&lt;span style=&quot;color: #660066;&quot;&gt;min&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;a&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; b&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;arr.&lt;span style=&quot;color: #660066;&quot;&gt;push&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;val&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; min &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; a &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; b &lt;span style=&quot;color: #339933;&quot;&gt;?&lt;/span&gt; a &lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; b&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;arr&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;arr.&lt;span style=&quot;color: #660066;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; val&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Pass_functions.2C_not_strings.2C_to_setTimeout.28.29_and_setInterval.28.29&quot; id=&quot;Pass_functions.2C_not_strings.2C_to_setTimeout.28.29_and_setInterval.28.29&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Pass functions, not strings, to setTimeout() and setInterval() &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;If you pass a string into setTimeout() or setInterval() the string will be evaluated the same way as with eval which is slow. 
&lt;/li&gt;&lt;li&gt;Wrap your code into an anonymous function instead so that it can be interpreted and optimized during compilation. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;setInterval&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'doSomethingPeriodically()'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; 1000&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;setTimeOut&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'doSomethingAfterFiveSeconds()'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; 5000&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;setInterval&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;doSomethingPeriodically&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; 1000&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;setTimeOut&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;doSomethingAfterFiveSeconds&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; 5000&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Store_local_references_to_out-of-scope_variables&quot; id=&quot;Store_local_references_to_out-of-scope_variables&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Store local references to out-of-scope variables&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;When a function is executed an execution context is created and an activation object containing all local variables is pushed to the front of the context's scope chain. 
&lt;/li&gt;&lt;li&gt;Further in the chain, the slower the identifier resolution is, which means local variables are fastest. 
&lt;/li&gt;&lt;li&gt;By storing local references to frequently used out-of-scope variables reading and writing to variables is significantly faster. This is visible especially with global variables and other deep searches for identifier resolution. 
&lt;/li&gt;&lt;li&gt;Also in-scope variables (&lt;tt&gt;var myVar&lt;/tt&gt;) are faster than object property access (&lt;tt&gt;this.myVar&lt;/tt&gt;). 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; doSomething&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;text&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; divs &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementsByTagName&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'div'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; 0&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; l &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; divs.&lt;span style=&quot;color: #660066;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; l&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;        divs&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;innerHTML&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; text&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; doSomethingFaster&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;text&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; doc &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; get &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementsByTagName&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'div'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; 0&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; l &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; divs.&lt;span style=&quot;color: #660066;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; l&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;        divs&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;innerHTML&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; text&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;If you need to access an element (e.g. the head) inside a big loop using a localized DOM access ( get in the example) is faster. 
&lt;/p&gt;&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; doSomethingElseFaster&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; get &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementsByTagName&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; 0&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;100000&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;       get&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'head'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Sources:
&lt;a href=&quot;http://www.nczonline.net/blog/2009/02/10/javascript-variable-performance/JavaScript&quot; class=&quot;external text&quot; title=&quot;http://www.nczonline.net/blog/2009/02/10/javascript-variable-performance/JavaScript&quot; rel=&quot;nofollow&quot;&gt;Variable Performance&lt;/a&gt;, &lt;a href=&quot;http://www.slideshare.net/nzakas/java-script-variable-performance-presentation&quot; class=&quot;external text&quot; title=&quot;http://www.slideshare.net/nzakas/java-script-variable-performance-presentation&quot; rel=&quot;nofollow&quot;&gt;slides&lt;/a&gt;
&lt;a href=&quot;http://jsconf2009.com/stefanov_video.html&quot; class=&quot;external text&quot; title=&quot;http://jsconf2009.com/stefanov_video.html&quot; rel=&quot;nofollow&quot;&gt;High Performance Kick Ass Web Apps Video at JSCONF 2009&lt;/a&gt;
&lt;/p&gt;&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;a name=&quot;Tips_for_better_loading_performance&quot; id=&quot;Tips_for_better_loading_performance&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Tips for better loading performance&lt;/span&gt;&lt;/h2&gt;
&lt;a name=&quot;Load_scripts_without_blocking_for_faster_startup_and_to_show_a_splash_screen&quot; id=&quot;Load_scripts_without_blocking_for_faster_startup_and_to_show_a_splash_screen&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Load scripts without blocking for faster startup and to show a splash screen&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;When &amp;lt;script&amp;gt; tags are found in the HTML document the referenced script resources are downloaded and executed before the rendering engine can continue to download other resources which effectively blocks the rendering of the page below the tag. To avoid this blocking behaviour a script tag can be created via a mechanism known as a dynamic script tag injection. 
&lt;/li&gt;&lt;li&gt;This mechanism allows the rendering engine to immediately render and display the initial view (aka the splash screen) defined in HTML while the JavaScript resources are still being loaded and executed which leads to better user experience.
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/div.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;splash&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/script.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;script&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;my-script-file.js&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;a href=&quot;http://december.com/html/4/element/script.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;script&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/div.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;splash&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/code.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;code&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/code.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;code&lt;/span&gt;&lt;/a&gt; javascript&amp;gt;&lt;/span&gt;&lt;br /&gt;// JavaScript&lt;br /&gt;function loadScript(src, callback) {&lt;br /&gt;    var head = document.getElementsByTagName('head')[0];&lt;br /&gt;    var script = document.createElement('script'),&lt;br /&gt;    done = false;&lt;br /&gt;    script.setAttribute('src', src);&lt;br /&gt;    script.setAttribute('type', 'text/javascript');&lt;br /&gt;    script.setAttribute('charset', 'utf-8');&lt;br /&gt;    script.onload = script.onreadstatechange = function() {&lt;br /&gt;        if (!done &lt;span style=&quot;color: #ddbb00;&quot;&gt;&amp;amp;&amp;amp; (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #ddbb00;&quot;&gt;            done = true;&lt;/span&gt;&lt;br /&gt;            script.onload = script.onreadystatechange = null;&lt;br /&gt;                if (callback) {&lt;br /&gt;                    callback();&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;    }&lt;br /&gt;    head.insertBefore(script, head.firstChild);&lt;br /&gt;}&lt;br /&gt;&amp;nbsp;&lt;br /&gt;// load the my-script-file.js and display an alert dialog once the script has been loaded&lt;br /&gt;loadScript('my-script-file.js', function() { alert('my-script-file.js loaded.'); });&lt;/pre&gt;
&lt;p&gt;Sources: 
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.nczonline.net/blog/2009/07/28/the-best-way-to-load-external-javascript/&quot; class=&quot;external text&quot; title=&quot;http://www.nczonline.net/blog/2009/07/28/the-best-way-to-load-external-javascript/&quot; rel=&quot;nofollow&quot;&gt;The best way to load external JavaScript&lt;/a&gt;
&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://docs.dojocampus.org/dojo/require&quot; class=&quot;external text&quot; title=&quot;http://docs.dojocampus.org/dojo/require&quot; rel=&quot;nofollow&quot;&gt;Dojo require&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Add_an_Expires_or_a_Cache-Control_HTTP_header&quot; id=&quot;Add_an_Expires_or_a_Cache-Control_HTTP_header&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Add an Expires or a Cache-Control HTTP header &lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;Using Apache the Expires HTTP header and the max-age directive of the Cache-Control HTTP header in server responses can be configures in .htaccess. The syntax is as follows: 
&lt;/p&gt;&lt;p&gt;&lt;tt&gt;ExpiresDefault &quot;&amp;lt;base&amp;gt; [plus] {&amp;lt;num&amp;gt;  &amp;lt;type&amp;gt;}*&quot;&lt;/tt&gt;
&lt;tt&gt;ExpiresByType type/encoding &quot;&amp;lt;base&amp;gt; [plus] {&amp;lt;num&amp;gt; &amp;lt;type&amp;gt;}*&quot;&lt;/tt&gt;
&lt;/p&gt;&lt;p&gt;Example: 
&lt;tt&gt;ExpiresActive On &lt;/tt&gt;
&lt;tt&gt;ExpiresByType image/png &quot;access plus 1 year&quot;&lt;/tt&gt;
&lt;/p&gt;&lt;p&gt;Source: 
&lt;a href=&quot;http://httpd.apache.org/docs/2.2/mod/mod_expires.html&quot; class=&quot;external text&quot; title=&quot;http://httpd.apache.org/docs/2.2/mod/mod_expires.html&quot; rel=&quot;nofollow&quot;&gt;Apache mod_expires&lt;/a&gt;
&lt;/p&gt;
&lt;a name=&quot;Gzip_JavaScript_and_CSS_resources&quot; id=&quot;Gzip_JavaScript_and_CSS_resources&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Gzip JavaScript and CSS resources &lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;Below is a simple configuration to gzip not only JavaScript and CSS but also HTML, XML and JSON. To accomplish this, the following must be set in the Apache .htaccess: 
&lt;/p&gt;&lt;p&gt;&lt;tt&gt;AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/json &lt;/tt&gt;
&lt;/p&gt;&lt;p&gt;Source: 
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://httpd.apache.org/docs/2.0/mod/mod_deflate.html&quot; class=&quot;external text&quot; title=&quot;http://httpd.apache.org/docs/2.0/mod/mod_deflate.html&quot; rel=&quot;nofollow&quot;&gt;Apache mod_deflate&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Use_YUI_Compressor_or_JSMin_to_compress_the_code&quot; id=&quot;Use_YUI_Compressor_or_JSMin_to_compress_the_code&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Use YUI Compressor or JSMin to compress the code&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;The Best: &lt;a href=&quot;http://developer.yahoo.com/yui/compressor/&quot; class=&quot;external text&quot; title=&quot;http://developer.yahoo.com/yui/compressor/&quot; rel=&quot;nofollow&quot;&gt;YUI Compressor&lt;/a&gt; provides the best overall performance when you consider it as: Total_Speed = Time_to_Download + Time_to_Evaluate. Depends on Rhino and is not applicable for real-time compression. 
&lt;/li&gt;&lt;li&gt;Simple: &lt;a href=&quot;http://www.crockford.com/javascript/jsmin.html&quot; class=&quot;external text&quot; title=&quot;http://www.crockford.com/javascript/jsmin.html&quot; rel=&quot;nofollow&quot;&gt;JSMin&lt;/a&gt; has implementations in nearly all the languages and is applicable for real-time compression. After gzipping the size comes very close to that of YUI Compressor. 
&lt;/li&gt;&lt;li&gt;JSMin or YUI Compressor + gzipping is better performer than Dean Edwards' &lt;a href=&quot;http://dean.edwards.name/packer/&quot; class=&quot;external text&quot; title=&quot;http://dean.edwards.name/packer/&quot; rel=&quot;nofollow&quot;&gt;Packer&lt;/a&gt; + gzipping. Although Packer provides the smallest (byte-size) code it will evaluate much slower as the scripts are unpacked on the client-side using one pass of a RegExp? which introduces an overhead especially significant on slow mobile devices. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Sources 
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://ejohn.org/blog/library-loading-speed/&quot; class=&quot;external text&quot; title=&quot;http://ejohn.org/blog/library-loading-speed/&quot; rel=&quot;nofollow&quot;&gt;Library Loading Speed&lt;/a&gt;
&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.julienlecomte.net/blog/2007/08/13/&quot; class=&quot;external text&quot; title=&quot;http://www.julienlecomte.net/blog/2007/08/13/&quot; rel=&quot;nofollow&quot;&gt;Gzip Your Minified JavaScript Files&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Minimize_the_number_and_size_of_resources&quot; id=&quot;Minimize_the_number_and_size_of_resources&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Minimize the number and size of resources &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Concatenate multiple script into one. However, consider that some mobile browsers have limits in how big resources they keep in cache. 
&lt;/li&gt;&lt;li&gt;Always aim for the smallest code size prior to minification and re-factor to increase re-usable code, consider all resources: HTML, JavaScript, CSS, images, JSON loaded using XHR. 
&lt;/li&gt;&lt;li&gt;Minimize the number of resources per host to enable more efficient parallel loading of resources 
&lt;/li&gt;&lt;li&gt;Serve your content from different hosts to overcode HTTP/1.1 limitation of parallel loading of two resources per host.
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Load_scripts_without_blocking_parallel_downloads&quot; id=&quot;Load_scripts_without_blocking_parallel_downloads&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Load scripts without blocking parallel downloads &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Multiple scripts can be loaded in parallel without blocking using techniques such as via normal script src, XHR eval, XHR injection, script in iframe, script DOM element, script defer and document.write script tag. 
&lt;/li&gt;&lt;li&gt;Depending on your specific constraints (resources in the same/different domain, need to preserve script loading order, need to show browser loading indicator) you can do an informed decision by checking the decision tree in the following presentation (slide 26). 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a href=&quot;http://www.stevesouders.com/blog/2009/03/16/sxsw-slides/&quot; class=&quot;external text&quot; title=&quot;http://www.stevesouders.com/blog/2009/03/16/sxsw-slides/&quot; rel=&quot;nofollow&quot;&gt;Even Faster Websites - Steve Souders at SXSW ‘09&lt;/a&gt;
&lt;/p&gt;
&lt;a name=&quot;Couple_asynchronous_scripts&quot; id=&quot;Couple_asynchronous_scripts&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Couple asynchronous scripts &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;If you have inline script which depend on the script you have multiple options: hardcoded callback, &lt;tt&gt;window.onload&lt;/tt&gt;, timer, degrading script tags and script onload. 
&lt;/li&gt;&lt;li&gt;See slide 35 onwards for details: 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;a href=&quot;http://www.stevesouders.com/blog/2009/03/16/sxsw-slides/&quot; class=&quot;external text&quot; title=&quot;http://www.stevesouders.com/blog/2009/03/16/sxsw-slides/&quot; rel=&quot;nofollow&quot;&gt;Even Faster Websites- Steve Souders at SXSW ‘09&lt;/a&gt;
&lt;/p&gt;
&lt;a name=&quot;Move_inline_scripts_above_stylesheets&quot; id=&quot;Move_inline_scripts_above_stylesheets&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Move inline scripts above stylesheets &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Browsers download stylesheets in parallel with other resources that follow unless the stylesheet is followed by an inline script. 
&lt;/li&gt;&lt;li&gt;Workaround is to either avoid inline scripts or move them above stylesheets or below other resources (e.g. images, scripts) and use &amp;lt;link&amp;gt;, not @import. 
&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://stevesouders.com/cuzillion/?ex=10021&quot; class=&quot;external text&quot; title=&quot;http://stevesouders.com/cuzillion/?ex=10021&quot; rel=&quot;nofollow&quot;&gt;Live demo&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Use_iframes_sparingly&quot; id=&quot;Use_iframes_sparingly&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Use iframes sparingly &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Parent's onload doesn't fire until iframe and all its components are downloaded. 
&lt;/li&gt;&lt;li&gt;Workaround for Safari and Chrome is to set iframe src in JavaScript. 
&lt;/li&gt;&lt;li&gt;Scripts and stylesheets also block iframe from loading. 
&lt;ul&gt;&lt;li&gt;In IE and FF stylesheets in the parent block the iframe or its resources 
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;iframe shares connection pool with parent, typically 2 connections per host.
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;a name=&quot;Document_Object_Model_.28DOM.29_obscurities&quot; id=&quot;Document_Object_Model_.28DOM.29_obscurities&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Document Object Model (DOM) obscurities &lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;Source: &lt;a href=&quot;http://dev.opera.com/articles/view/efficient-javascript/?page=3&quot; class=&quot;external text&quot; title=&quot;http://dev.opera.com/articles/view/efficient-javascript/?page=3&quot; rel=&quot;nofollow&quot;&gt;Efficient JavaScript - DOM&lt;/a&gt;
&lt;/p&gt;&lt;p&gt;Slow DOM performance can be traced back into the following three main causes: 
&lt;/p&gt;
&lt;table border=&quot;1&quot;&gt;
&lt;tr&gt;
&lt;td&gt;Extensive DOM manipulation
&lt;/td&gt;&lt;td&gt;Extensive use of DOM API is a well-known cause of slowness.
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Script triggers too many reflows or repaints
&lt;/td&gt;&lt;td&gt;As a consequence of DOM manipulation, reflowing the layout and repainting are very expensive.
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Slow approach to locating nodes in the DOM
&lt;/td&gt;&lt;td&gt;Locating a desired node(s) in the DOM is potential bottleneck if the DOM is sizable and/or complex.
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;a name=&quot;Minimize_the_size_of_the_DOM&quot; id=&quot;Minimize_the_size_of_the_DOM&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Minimize the size of the DOM &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;The size of DOM slows down all the operation related to it such as reflowing, traversal and DOM manipulation. 
&lt;/li&gt;&lt;li&gt;The most effective way to make programs faster is to make n smaller means that the DOM should be as small as possible at all times. 
&lt;/li&gt;&lt;li&gt;Minimize n, you can track the number of elements in a page by: 
&lt;ul&gt;&lt;li&gt;&lt;tt&gt;var n = document.getElementsByTagName('*').length;&lt;/tt&gt;
&lt;/li&gt;&lt;li&gt;&lt;tt&gt;var n = $('*').length;&lt;/tt&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Use_document_fragment_templates_for_re-usability&quot; id=&quot;Use_document_fragment_templates_for_re-usability&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Use document fragment templates for re-usability &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Dynamically inserting and updating elements into the DOM is expensive. An efficient way to tackle this is to use HTML templates which can be cloned and re-used for re-usable parts of the DOM such as dialogs and other UI widgets. 
&lt;/li&gt;&lt;li&gt;In practice the approach is to modify, clone and append all nodes in JavaScript without touching the live DOM and append the completed document fragment to the DOM at once. One can do this with DOM API or alternatively construct a string representation of the HTML fragment to append based on a string template and push that into the DOM with a one innerHTML assignment. On both cases the rendering engine does not have to reflow and repaint the layout multiple times. Next we introduce some techniques to achieve this behavior.
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Minimize_the_number_of_reflows_and_repaints&quot; id=&quot;Minimize_the_number_of_reflows_and_repaints&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Minimize the number of reflows and repaints &lt;/span&gt;&lt;/h3&gt;
&lt;table border=&quot;1&quot;&gt;
&lt;tr&gt;
&lt;td&gt;Repaint
&lt;/td&gt;&lt;td&gt;Repainting happens when something is made visible or hidden without altering the layout of the document. For example if an outline is added to an element, its background color is changed of its visiblity is changed. Repainting is an expensive operation (&lt;a href=&quot;http://ejohn.org/blog/browser-paint-events/&quot; class=&quot;external text&quot; title=&quot;http://ejohn.org/blog/browser-paint-events/&quot; rel=&quot;nofollow&quot;&gt;paint events demo&lt;/a&gt;).
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reflow
&lt;/td&gt;&lt;td&gt;Reflow happens whenever the DOM is manipulated in a way it affects the layout. For example, style is changed to affect the layout, className property is changed or browser window size is changed. Once an element needs to be reflown, its children wil also be reflown and any elements appearing after the element in the DOM. Finally, everything is repainted. Reflows are even more expensive operations, than repainting. In many cases reflowing is comparable to layout out the entire page again (&lt;a href=&quot;http://www.youtube.com/watch?v=dndeRnzkJDU&quot; class=&quot;external text&quot; title=&quot;http://www.youtube.com/watch?v=dndeRnzkJDU&quot; rel=&quot;nofollow&quot;&gt;reflow demo videos&lt;/a&gt;).
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;ul&gt;&lt;li&gt;Operation that trigger reflows should be used sparsely. 
&lt;/li&gt;&lt;li&gt;Reflowing a table element is more expensive that reflowing equivalent element with block display. 
&lt;/li&gt;&lt;li&gt;Elements that are positioned absolutely or fixed do not affect the main document layout, so their reflowing is cheaper as they do not trigger main document reflowing. This is recommended approach for element that need to be animated. 
&lt;/li&gt;&lt;li&gt;DOM modifications trigger reflow. This means that operations such as adding new elements, changing the value of text nodes or adding element attributes and their properties cause reflow. 
&lt;/li&gt;&lt;li&gt;Good strategies to overcome this limitation are elaborated next.
&lt;/li&gt;&lt;/ul&gt;
&lt;ul&gt;&lt;li&gt;Further reading 
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://dev.opera.com/articles/view/efficient-javascript/?page=3#reflow&quot; class=&quot;external text&quot; title=&quot;http://dev.opera.com/articles/view/efficient-javascript/?page=3#reflow&quot; rel=&quot;nofollow&quot;&gt;Repaint and reflow at Opera Developer Network &lt;/a&gt;
&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.mozilla.org/newlayout/doc/reflow.html&quot; class=&quot;external text&quot; title=&quot;http://www.mozilla.org/newlayout/doc/reflow.html&quot; rel=&quot;nofollow&quot;&gt;Notes on HTML Reflow &lt;/a&gt;- more detailed information on the reflow process 
&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/&quot; class=&quot;external text&quot; title=&quot;http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/&quot; rel=&quot;nofollow&quot;&gt;Reflows &amp;amp; Repaints: CSS Performance making your JavaScript slow&lt;/a&gt;
&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.slideshare.net/lsimon/go-with-the-reflow&quot; class=&quot;external text&quot; title=&quot;http://www.slideshare.net/lsimon/go-with-the-reflow&quot; rel=&quot;nofollow&quot;&gt;Go With The Reflow &lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;Tools 
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/9954&quot; class=&quot;external text&quot; title=&quot;https://addons.mozilla.org/en-US/firefox/addon/9954&quot; rel=&quot;nofollow&quot;&gt;XUL Profiler&lt;/a&gt;
&lt;/li&gt;&lt;li&gt;Mac OS X Quartz Debug (in developer tools part of every OS X) Autoflush drawing setting illustrates how the page is reflown in step-by-step detail. (&lt;a href=&quot;http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/&quot; class=&quot;external text&quot; title=&quot;http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/&quot; rel=&quot;nofollow&quot;&gt;more&lt;/a&gt;)
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Use_createDocumentFragment.28.29&quot; id=&quot;Use_createDocumentFragment.28.29&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Use createDocumentFragment() &lt;/span&gt;&lt;/h4&gt;
&lt;ul&gt;&lt;li&gt;Make multiple changes in a DOMDocumentFragment and add the fragment into the DOM in a single operation. This triggers only one reflow. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; list &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'foo'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'bar'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'baz'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elem&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; contents&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; list.&lt;span style=&quot;color: #660066;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    elem &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;createElement&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'div'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    content &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;createTextNode&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;list&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    elem.&lt;span style=&quot;color: #660066;&quot;&gt;appendChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;content&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    document.&lt;span style=&quot;color: #660066;&quot;&gt;body&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;appendChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;elem&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; fragment &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;createDocumentFragment&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; list &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'foo'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'bar'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'baz'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elem&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; contents&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; list.&lt;span style=&quot;color: #660066;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    elem &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;createElement&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'div'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    content &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;createTextNode&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;list&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    fragment.&lt;span style=&quot;color: #660066;&quot;&gt;appendChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;content&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;document.&lt;span style=&quot;color: #660066;&quot;&gt;body&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;appendChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;fragment&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Use_cloneNode.28.29&quot; id=&quot;Use_cloneNode.28.29&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Use cloneNode() &lt;/span&gt;&lt;/h4&gt;
&lt;ul&gt;&lt;li&gt;If you're not working on elements that do not contain form elements or event handlers, you can clone the element to modify and swap it in place after all the changes have been done resulting in a one reflow only. 
&lt;/li&gt;&lt;li&gt;A faster alternative to above slow approach is presented below. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; orig &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'container'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; clone &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; orig.&lt;span style=&quot;color: #660066;&quot;&gt;cloneNode&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; list &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'foo'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'bar'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'baz'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;clone.&lt;span style=&quot;color: #660066;&quot;&gt;setAttribute&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'width'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'50%'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elem&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; contents&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt;  &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; list.&lt;span style=&quot;color: #660066;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    elem &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;createElement&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'div'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    content &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;createTextNode&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;list&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    elem.&lt;span style=&quot;color: #660066;&quot;&gt;appendChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;content&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    clone.&lt;span style=&quot;color: #660066;&quot;&gt;appendChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;elem&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;original.&lt;span style=&quot;color: #660066;&quot;&gt;parentNode&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;replaceChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;clone&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; original&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Use_HTML_templates_and_innerHTML&quot; id=&quot;Use_HTML_templates_and_innerHTML&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Use HTML templates and innerHTML &lt;/span&gt;&lt;/h4&gt;
&lt;ul&gt;&lt;li&gt;One way to implement a templating system is to populate template content based on a light-weight JavaScript object acting as a date model. The data model may be persisted as JSON serialization into e.g. &lt;a href=&quot;http://library.forum.nokia.com/topic/Web_Developers_Library/GUID-DF4D8745-B6D4-4BC4-AF2D-0F71F28E9F27.html&quot; class=&quot;external text&quot; title=&quot;http://library.forum.nokia.com/topic/Web_Developers_Library/GUID-DF4D8745-B6D4-4BC4-AF2D-0F71F28E9F27.html&quot; rel=&quot;nofollow&quot;&gt;&lt;tt&gt;setPreferenceForKey()&lt;/tt&gt;&lt;/a&gt; store in S60 WRT, in a HTTP cookie or XHR'd to the server-side. 
&lt;/li&gt;&lt;/ul&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;nowiki&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; model &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt; title&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'My Test Page'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; template &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;template.&lt;span style=&quot;color: #660066;&quot;&gt;push&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'&amp;lt;h1&amp;gt;'&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; model.&lt;span style=&quot;color: #660066;&quot;&gt;title&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'&amp;lt;h1&amp;gt;'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;template.&lt;span style=&quot;color: #660066;&quot;&gt;push&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'&amp;lt;div&amp;gt;Another Test Element&amp;lt;div&amp;gt;'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;containerId&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;innerHTML&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; template.&lt;span style=&quot;color: #660066;&quot;&gt;join&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;''&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;br /&gt;&lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// alternatively you can use concat() -- see string concatenation test results&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;/&lt;/span&gt;nowiki&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Modify_an_invisible_element&quot; id=&quot;Modify_an_invisible_element&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Modify an invisible element &lt;/span&gt;&lt;/h4&gt;
&lt;ul&gt;&lt;li&gt;If the display property of an element is set to none it will not be repainted. 
&lt;/li&gt;&lt;li&gt;By setting display to none, do the modifications and then set it to block causes only two reflows 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; subElem &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;createElement&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'div'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elem &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'animated'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;appendChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;subElem&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;style&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;width&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'320px'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; subElem &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;createElement&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'div'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elem &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'animated'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;style&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;display&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'none'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;appendChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;subElem&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;style&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;width&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'320px'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;style&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;display&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'block'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Minimize_the_use_of_operations_determining_the_dimensions_or_location_of_elements&quot; id=&quot;Minimize_the_use_of_operations_determining_the_dimensions_or_location_of_elements&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Minimize the use of operations determining the dimensions or location of elements &lt;/span&gt;&lt;/h4&gt;
&lt;ul&gt;&lt;li&gt;Determining dimensions or location of elements via getComputedStyle, offsetWidth, scrollWidth and clientWidth properties will force reflow. 
&lt;/li&gt;&lt;li&gt;If you take the measurements repeatedly, consider taking them only once. 
&lt;/li&gt;&lt;li&gt;This issue is the main cause of slowness in WebKit according to &lt;a href=&quot;http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/#comment-13157&quot; class=&quot;external text&quot; title=&quot;http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/#comment-13157&quot; rel=&quot;nofollow&quot;&gt;Dave Hyatt&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elem &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'animated'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;style&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;fontSize&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;offsetWidth&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'px'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;firstChild&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;style&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;marginleft&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;offsetWidth&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'px'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elem &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'animated'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elemWidth &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; elem.&lt;span style=&quot;color: #660066;&quot;&gt;offsetWidth&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;style&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;fontSize&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;elemWidth &lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'px'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;firstChild&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;style&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;marginleft&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;elemWidth &lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'px'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Make_multiple_predefined_style_changes_at_once_using_className&quot; id=&quot;Make_multiple_predefined_style_changes_at_once_using_className&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Make multiple predefined style changes at once using className &lt;/span&gt;&lt;/h4&gt;
&lt;ul&gt;&lt;li&gt;As with DOM manipulation, several style changes can be done at the same time. 
&lt;/li&gt;&lt;li&gt;Instead if you set the styles one by one, multiple reflows and repaints can be triggered. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elem &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'styled'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;style&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;background&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'blue'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;style&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;color&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'white'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;Faster&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;br /&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;code html4strict&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;style type&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;div &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt; background&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; white&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; color&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; black&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;div.&lt;span style=&quot;color: #660066;&quot;&gt;active&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt; background&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; blue&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; color&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; white&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;/&lt;/span&gt;style&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;...&lt;/pre&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elem &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'styled'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;className&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'active'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Make_multiple_dynamic_style_changes_at_once_using_setAttribute&quot; id=&quot;Make_multiple_dynamic_style_changes_at_once_using_setAttribute&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Make multiple dynamic style changes at once using setAttribute &lt;/span&gt;&lt;/h4&gt;
&lt;ul&gt;&lt;li&gt;For dynamic animation, using predefined styles does not work. In this case setAttribute object can be used (for IE, use style.cssText property) 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elem &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'styled'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;elemStyle &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'background: blue; color: white;'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;setAttribute&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'style'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; elemStyle&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;a name=&quot;CSS_class_name_vs._style_property_changing&quot; id=&quot;CSS_class_name_vs._style_property_changing&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;CSS class name vs. style property changing &lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;Changing the class name of an element is a nice way to use JavaScript to dynamically change elements. Performance varies from browser to browser, but generally it is faster to change an element's visual appearance directly via the Javascript style attribute, rather than to change a class name on that element. 
&lt;/p&gt;&lt;p&gt;Slow: 
&lt;tt&gt;div.active { border: 1px solid red; }&lt;/tt&gt;
&lt;/p&gt;&lt;p&gt;Faster (for a one element): 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; container &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'container'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;container.&lt;span style=&quot;color: #660066;&quot;&gt;style&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;border&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'1px solid red'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;The above method appears to be more efficient when changing a specific number of items. Sometimes a single class name change is effective however. If you need to change all elements under a given container for example, it is more efficient to change the class name of a parent container which holds the affected elements and let CSS do what it does best. 
&lt;/p&gt;&lt;p&gt;Faster (if multiple child elements of a container need to be changed): 
&lt;tt&gt;// by changing the class name of the container, all of its child div elements will be updated&lt;/tt&gt;
&lt;tt&gt;#container.active div { border: 1px solid red; } &lt;/tt&gt;
&lt;/p&gt;&lt;p&gt;Depending on the specific case at hand you should use the method which gives you the best performance (without sacrificing too much of the separation of concerns benefits of externally defined CSS). 
&lt;/p&gt;&lt;p&gt;Source:
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://schillmania.com/content/entries/2009/yahoo-photos-frontend-thoughts/&quot; class=&quot;external text&quot; title=&quot;http://schillmania.com/content/entries/2009/yahoo-photos-frontend-thoughts/&quot; rel=&quot;nofollow&quot;&gt;A Snapshot of The Yahoo! Photos Beta - Web Development Perspective&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Avoid_traversing_large_number_of_nodes&quot; id=&quot;Avoid_traversing_large_number_of_nodes&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Avoid traversing large number of nodes &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Always try to use inbuild methods and collections of the DOM to narrow down the search to smallest number of nodes possible. 
&lt;/li&gt;&lt;li&gt;Try to avoid manually recursively stepping through the DOM as much as possible. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elements &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementsByTagName&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'*'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// searches every element, slow&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; elements.&lt;span style=&quot;color: #660066;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;element&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;hasAttribute&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'selected'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// continues even through element was found&lt;/span&gt;&lt;br /&gt;        ...&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elements &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'parent'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;childNodes&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// we know the element is a child of parent&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; elements.&lt;span style=&quot;color: #660066;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;element&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;nodeType&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; element&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;hasAttribute&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'selected'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// first test for valid node type&lt;/span&gt;&lt;br /&gt;        ...&lt;br /&gt;        &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;break&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// break out of the loop if we found what we were looking for&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Avoid_modifications_while_traversing&quot; id=&quot;Avoid_modifications_while_traversing&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Avoid modifications while traversing&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;childNodes and NodeList returned by getElementsByTagName() are live. This means that these collections may change without waiting for the execution to finish first. 
&lt;/li&gt;&lt;li&gt;If new elements are added to the collections while they are traversed, an infinite loop may occur. 
&lt;/li&gt;&lt;li&gt;If new elements are added even outside of collection itself, the collection must look for potential new entries. Due to this it cannot remember its last position or length which need to be recalculated. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elems &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementsByTagName&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'div'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; elems.&lt;span style=&quot;color: #660066;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    elems&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;appendChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;document.&lt;span style=&quot;color: #660066;&quot;&gt;createTextNode&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elems &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementsByTagName&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'div'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; temp &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; elems.&lt;span style=&quot;color: #660066;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    temp&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; elems&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// first a build static list of elements to modify&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; temp.&lt;span style=&quot;color: #660066;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    temp&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;appendChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;document.&lt;span style=&quot;color: #660066;&quot;&gt;createTextNode&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// perform modifications on static list instead of live NodeList&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;temp &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Cache_DOM_values_into_variables&quot; id=&quot;Cache_DOM_values_into_variables&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Cache DOM values into variables &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Cache frequently accessed DOM values into variables. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow:
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'elem'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;propertyOne&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'value of first property'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'elem'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;propertyTwo&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'value of second property'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'elem'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;propertyThree&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'value of third property'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster:
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elem &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'elem'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;propertyOne&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'value of first property'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;propertyTwo&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'value of second property'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;elem.&lt;span style=&quot;color: #660066;&quot;&gt;propertyThree&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'value of third property'&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Remove_references_to_documents_that_have_been_closed&quot; id=&quot;Remove_references_to_documents_that_have_been_closed&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Remove references to documents that have been closed&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;If a reference to frame, iframe or object is stored in a global variable or a property, clear it by setting it to null or deleting it. 
&lt;/li&gt;&lt;li&gt;For example, a popup window that is closed and has a reference to global variable, will be kept in memory although the document itself is no longer loaded, if it is not deleted manually. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; frame &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; parent.&lt;span style=&quot;color: #660066;&quot;&gt;frames&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'frameId'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;document&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; container &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; frame.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'contentId'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; content &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; frame.&lt;span style=&quot;color: #660066;&quot;&gt;createElement&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'div'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;content.&lt;span style=&quot;color: #660066;&quot;&gt;appendChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;frame.&lt;span style=&quot;color: #660066;&quot;&gt;createTextNode&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'Some content'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;container.&lt;span style=&quot;color: #660066;&quot;&gt;appendChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;content&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; frame &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; parent.&lt;span style=&quot;color: #660066;&quot;&gt;frames&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'frameId'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;document&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; container &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; frame.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'contentId'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; content &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; frame.&lt;span style=&quot;color: #660066;&quot;&gt;createElement&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'div'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;content.&lt;span style=&quot;color: #660066;&quot;&gt;appendChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;frame.&lt;span style=&quot;color: #660066;&quot;&gt;createTextNode&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'Some content'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;container.&lt;span style=&quot;color: #660066;&quot;&gt;appendChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;content&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// nullify references to frame&lt;/span&gt;&lt;br /&gt;frame &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;container &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;content &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Object-Oriented_JavaScript&quot; id=&quot;Object-Oriented_JavaScript&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Object-Oriented JavaScript &lt;/span&gt;&lt;/h2&gt;
&lt;a name=&quot;Consider_alternative_inheritance_mechanisms&quot; id=&quot;Consider_alternative_inheritance_mechanisms&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Consider alternative inheritance mechanisms &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;There exists many ways to mimic Object Orientated style inheritance in JavaScript. However, not all the mechanism to emulate inheritance perform similarly. 
&lt;/li&gt;&lt;li&gt;Especially if your code calls overridden methods frequently you should take a look at the &lt;a href=&quot;http://www.broofa.com/blog/2009/02/javascript-inheritance-performance&quot; class=&quot;external text&quot; title=&quot;http://www.broofa.com/blog/2009/02/javascript-inheritance-performance&quot; rel=&quot;nofollow&quot;&gt;results of JavaScript Inheritance Performance&lt;/a&gt; study.
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Client-server_communication&quot; id=&quot;Client-server_communication&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Client-server communication &lt;/span&gt;&lt;/h2&gt;
&lt;a name=&quot;Set_timeouts_to_XMLHttpRequests&quot; id=&quot;Set_timeouts_to_XMLHttpRequests&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Set timeouts to XMLHttpRequests &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Browsers will timeout XHR requests after some time, but sometimes it is beneficial to abort the connection under script control. This can be done by adding timeouts to XHR calls using setTimeout(). 
&lt;/li&gt;&lt;/ul&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; xhr &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;new&lt;/span&gt; XMLHttpRequest &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;xhr.&lt;span style=&quot;color: #000066;&quot;&gt;open&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'GET'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; url&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;xhr.&lt;span style=&quot;color: #660066;&quot;&gt;onreadystatechange&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;readyState&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; 4&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;                    &lt;br /&gt;        clearTimeout&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;timeout&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// do something with response data&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; timeout &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; setTimeout&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;br /&gt;    &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;        xhr.&lt;span style=&quot;color: #660066;&quot;&gt;abort&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// call error callback&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #CC0000;&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #CC0000;&quot;&gt;1000&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// timeout after a minute&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;xhr.&lt;span style=&quot;color: #660066;&quot;&gt;send&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Consider_using_a_custom_data_exchange_format_for_large_datasets.2C_as_an_alternative_to_XML_and_JSON&quot; id=&quot;Consider_using_a_custom_data_exchange_format_for_large_datasets.2C_as_an_alternative_to_XML_and_JSON&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Consider using a custom data exchange format for large datasets, as an alternative to XML and JSON&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Depending on the browser, its version and OS, the performance difference between XML or JSON parsing and traversing may be very significant. For example, on Nokia 5800 XpressMusic with a very large dataset JSON is approx. 5x faster. 
&lt;/li&gt;&lt;li&gt;Using a custom string-based data format (think CSV) over XML and JSON is efficient in terms of transferred bytes and parse time with large datasets. 
&lt;/li&gt;&lt;li&gt;Using JavaScript’s String and RegExp methods one can match the speed of JSON executed natively with as little overhead to the filesize as possible. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;JSON: 
&lt;tt&gt;var contacts = JSON.parse(o.responseText);&lt;/tt&gt;
&lt;/p&gt;&lt;p&gt;Equivalent using custom data format and String and RegExp methods: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;that.&lt;span style=&quot;color: #660066;&quot;&gt;contacts&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; o.&lt;span style=&quot;color: #660066;&quot;&gt;responseText&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;split&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;c&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; n &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; 0&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; len &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; that.&lt;span style=&quot;color: #660066;&quot;&gt;contacts&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; contactSplit&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; n &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; len&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; n&lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;   contactSplit &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; that.&lt;span style=&quot;color: #660066;&quot;&gt;contacts&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;n&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;split&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\\&lt;/span&gt;a&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;   that.&lt;span style=&quot;color: #660066;&quot;&gt;contacts&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;n&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;   that.&lt;span style=&quot;color: #660066;&quot;&gt;contacts&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;n&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;n&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; contactSplit&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;0&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;   that.&lt;span style=&quot;color: #660066;&quot;&gt;contacts&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;n&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;e&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; contactSplit&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;1&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;   that.&lt;span style=&quot;color: #660066;&quot;&gt;contacts&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;n&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;u&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; contactSplit&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;2&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;   that.&lt;span style=&quot;color: #660066;&quot;&gt;contacts&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;n&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;r&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; contactSplit&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;3&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;   that.&lt;span style=&quot;color: #660066;&quot;&gt;contacts&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;n&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;s&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; contactSplit&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;4&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;   that.&lt;span style=&quot;color: #660066;&quot;&gt;contacts&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;n&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;f&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; contactSplit&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;5&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;   that.&lt;span style=&quot;color: #660066;&quot;&gt;contacts&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;n&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;a&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; contactSplit&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;6&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;   that.&lt;span style=&quot;color: #660066;&quot;&gt;contacts&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;n&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;d&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; contactSplit&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;7&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;   that.&lt;span style=&quot;color: #660066;&quot;&gt;contacts&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;n&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;y&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; contactSplit&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;8&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Sources: 
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://code.flickr.com/blog/2009/03/18/building-fast-client-side-searches/&quot; class=&quot;external text&quot; title=&quot;http://code.flickr.com/blog/2009/03/18/building-fast-client-side-searches/&quot; rel=&quot;nofollow&quot;&gt;Building Fast Client-side Searches &lt;/a&gt;
&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://ejohn.org/blog/native-json-support-is-required/&quot; class=&quot;external text&quot; title=&quot;http://ejohn.org/blog/native-json-support-is-required/&quot; rel=&quot;nofollow&quot;&gt;Native JSON Support is Required&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Animations&quot; id=&quot;Animations&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Animations &lt;/span&gt;&lt;/h2&gt;
&lt;a name=&quot;Use_animations_modestly&quot; id=&quot;Use_animations_modestly&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Use animations modestly &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Animation without hardware support is slow. Try to avoid excessive use of animations which do not bring any real usability value. At least give users an opportunity to disable animations.
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Use_scrollTo.28.29_to_animate_scrolling&quot; id=&quot;Use_scrollTo.28.29_to_animate_scrolling&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Use scrollTo() to animate scrolling &lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;Using native scrolling via scrollTo() performs significantly better as it does not trigger reflow.
&lt;/p&gt;
&lt;a name=&quot;Absolutely_or_fixed_position_animated_elements&quot; id=&quot;Absolutely_or_fixed_position_animated_elements&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Absolutely or fixed position animated elements &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;By default elements have style property position: static and animating such elements causes reflowing of the layout and is expensive. 
&lt;/li&gt;&lt;li&gt;Elements to be animated should be set as position: absolute or position: fixed if reflowing is not mandatory for smoother animation and lesser CPU load. Such elements do not affect other elements layout, so they will only cause a repaint rather than a full reflow with a nice performance boost. 
&lt;/li&gt;&lt;li&gt;CSS positioning schemes for position property:
&lt;/li&gt;&lt;/ul&gt;
&lt;table border=&quot;1&quot;&gt;

&lt;tr&gt;
&lt;th&gt;Position value
&lt;/th&gt;&lt;th&gt;Description
&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;static
&lt;/td&gt;&lt;td&gt;Default. An element with position: static always has the position the normal flow of the page gives it (a static element ignores any top, bottom, left, or right declarations)
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;relative
&lt;/td&gt;&lt;td&gt;An element with position: relative moves an element relative to its normal position, so left:20 adds 20 pixels to the element's left position
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;absolute
&lt;/td&gt;&lt;td&gt;An element with position: absolute is positioned at the specified coordinates relative to its containing block. The element's position is specified with the left, top, right, and bottom properties.
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;fixed
&lt;/td&gt;&lt;td&gt;An element with position: fixed is positioned at the specified coordinates relative to the browser window. The element's position is specified with the left, top, right, and bottom properties. The element remains at that position regardless of scrolling.
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;Source: 
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.w3schools.com/Css/pr_class_position.asp&quot; class=&quot;external text&quot; title=&quot;http://www.w3schools.com/Css/pr_class_position.asp&quot; rel=&quot;nofollow&quot;&gt;w3schools - CSS position Property&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Use_one_timer_to_animate_multiple_elements_at_the_same_time&quot; id=&quot;Use_one_timer_to_animate_multiple_elements_at_the_same_time&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Use one timer to animate multiple elements at the same time &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;&lt;tt&gt;setTimeout()&lt;/tt&gt; and &lt;tt&gt;setInterval()&lt;/tt&gt; timers are two basic methods used to implement animation (i.e. trigger changes to element size, position and/or appearance over time).
&lt;/li&gt;&lt;li&gt;If multiple elements are animated at the same time, the best framerate is achieved by iterating across all animated elements inside a single loop. Using multiple timers makes animation less efficient and consistent, presumably due to timer invocation overhead. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;setInterval&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    animateFirst&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;arg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; 50&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;setInterval&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    animateSecond&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;arg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; 50&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; animateFirst&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;arg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; animateSecond&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;arg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;setInterval&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    animateFirst&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;arg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    animateSecond&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;arg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; 50&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; animateFirst&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;arg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; animateSecond&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;arg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Sources, further reading: 
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.schillmania.com/content/projects/javascript-animation-1/&quot; class=&quot;external text&quot; title=&quot;http://www.schillmania.com/content/projects/javascript-animation-1/&quot; rel=&quot;nofollow&quot;&gt;Javascript Animation: Tutorial, Part 1 &lt;/a&gt;
&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.schillmania.com/content/projects/javascript-animation-2/&quot; class=&quot;external text&quot; title=&quot;http://www.schillmania.com/content/projects/javascript-animation-2/&quot; rel=&quot;nofollow&quot;&gt;Javascript Animation: Tutorial, Part 2&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Trade_animation_smoothness_for_speed&quot; id=&quot;Trade_animation_smoothness_for_speed&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Trade animation smoothness for speed&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;To trade smoothness for speed means that while you may want to move an animation 1 pixel at a time, the animation and subsequent reflows may in that case use 100% of the CPU and the animation will seem jumpy as the browser is forced to drop frames to update the flow. Moving the animated element by e.g. 5 pixels at a time may seem slightly less smooth on faster machines, but won’t cause CPU thrashing that easily on mobile devices.
&lt;/p&gt;&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;a name=&quot;Events&quot; id=&quot;Events&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Events &lt;/span&gt;&lt;/h2&gt;
&lt;a name=&quot;Use_event_delegation&quot; id=&quot;Use_event_delegation&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Use event delegation &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Assigning event handlers to individual objects can add up quickly and is expensive if you create a lots of new elements dynamically to which event handlers need to be bound.
&lt;/li&gt;&lt;li&gt;This becomes especially interesting if you assign multiple event listeners (e.g. click and blur to a one element. In case of 100 elements that would mean 200 event handlers. 
&lt;/li&gt;&lt;li&gt;Using DOM Level 2 event model all events propagate toward the document object which is highest up in the hierarchy. This means that one can bind event listeners to document which invokes a controller and passes the event object to it. The controller is responsible for inspecting the internals of the event and dispatching to appropriate logic. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; elems &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;first&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; ...&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; last&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// an array which holds say 1000 references to element to which assign the event handlers to&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; l &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; elems.&lt;span style=&quot;color: #660066;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;++;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; l&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    elems&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;onclick&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    elems&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #000066;&quot;&gt;onblur&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
//HTML
&amp;lt;button id=&quot;doSomething&quot;&amp;gt;Click me to do something&amp;lt;/button&amp;gt; // you can add more of elements without the need to worry about binding event handlers
&lt;/p&gt;&lt;p&gt;&amp;lt;/code&amp;gt;
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// JS&lt;/span&gt;&lt;br /&gt;document.&lt;span style=&quot;color: #660066;&quot;&gt;addEventListener&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'click'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;event&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt; eventController&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;event&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;document.&lt;span style=&quot;color: #660066;&quot;&gt;addEventListener&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'blue'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;event&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt; eventController&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;event&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; eventController&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;event&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;   &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// inspect the event object internals and do something wise&lt;/span&gt;&lt;br /&gt;   &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;event.&lt;span style=&quot;color: #660066;&quot;&gt;target&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;id&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;===&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'doSomething'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;      doSomething&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;   &lt;br /&gt;   &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; doSomething&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Throttle_event_handlers_which_fire_excessively&quot; id=&quot;Throttle_event_handlers_which_fire_excessively&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Throttle event handlers which fire excessively &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;If a handler is called many times, the responsiveness of the UI degrade and tops the CPU. This is especially an issue if the event handler triggers reflow as is the case with resize. 
&lt;/li&gt;&lt;li&gt;On S60 5.0 devices input element's blur handler is called each time the content of the input field changes, e.g. user types in a single letter. 
&lt;/li&gt;&lt;li&gt;You may want your function to run once after the last event has fired to prevent excessive calls to potentially expensive functions. You must implement throttling mechanism to achieve that kind of a rate limited. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;window.&lt;span style=&quot;color: #000066;&quot;&gt;onresize&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; resizeHandler&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// fires excessively during resize&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; SomeObject&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;     &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; self &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;     &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;lastExecThrottle&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;500&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// limit to one call every &amp;quot;n&amp;quot; msec&lt;/span&gt;&lt;br /&gt;     &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;lastExec&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;new&lt;/span&gt; Date&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;     &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;timer&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;     &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;resizeHandler&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;         &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; d &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;new&lt;/span&gt; Date&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;         &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;d&lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;self.&lt;span style=&quot;color: #660066;&quot;&gt;lastExec&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; self.&lt;span style=&quot;color: #660066;&quot;&gt;lastExecThrottle&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;             &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// This function has been called &amp;quot;too soon,&amp;quot; before the allowed &amp;quot;rate&amp;quot; of twice per second&lt;/span&gt;&lt;br /&gt;             &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// Set (or reset) timer so the throttled handler execution happens &amp;quot;n&amp;quot; msec from now instead&lt;/span&gt;&lt;br /&gt;             &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;self.&lt;span style=&quot;color: #660066;&quot;&gt;timer&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;                 window.&lt;span style=&quot;color: #660066;&quot;&gt;clearTimeout&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;self.&lt;span style=&quot;color: #660066;&quot;&gt;timer&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;             &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;             self.&lt;span style=&quot;color: #660066;&quot;&gt;timer&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; window.&lt;span style=&quot;color: #660066;&quot;&gt;setTimeout&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;self.&lt;span style=&quot;color: #660066;&quot;&gt;resizeHandler&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; self.&lt;span style=&quot;color: #660066;&quot;&gt;lastExecThrottle&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;             &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// exit&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;        self.&lt;span style=&quot;color: #660066;&quot;&gt;lastExec&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; d&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// update &amp;quot;last exec&amp;quot; time&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// At this point, actual handler code can be called (update positions, resize elements etc.)&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// self.callResizeHandlerFunctions();&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; someObject &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;new&lt;/span&gt; SomeObject&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;window.&lt;span style=&quot;color: #000066;&quot;&gt;onresize&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; someObject.&lt;span style=&quot;color: #660066;&quot;&gt;resizeHandler&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Source: 
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://schillmania.com/content/entries/2009/yahoo-photos-frontend-thoughts/&quot; class=&quot;external text&quot; title=&quot;http://schillmania.com/content/entries/2009/yahoo-photos-frontend-thoughts/&quot; rel=&quot;nofollow&quot;&gt;A Snapshot of The Yahoo! Photos Beta - Web Development Perspective&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Escaping_the_JavaScript_call_stack_with_setTimeout&quot; id=&quot;Escaping_the_JavaScript_call_stack_with_setTimeout&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Escaping the JavaScript call stack with &lt;tt&gt;setTimeout&lt;/tt&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Setting up handlers that run after an event has fired needs some trickery. Because the event doesn’t take effect until the event-handling call stack opens and closes completely, there’s no way to work in a post-event environment via conventional event handlers. 
&lt;/li&gt;&lt;li&gt;When something is called using setTimeout with a delay of 0 the JavaScript engine notices it is busy (with a task which invoked &lt;tt&gt;setTimeout&lt;/tt&gt;) and queues the &lt;tt&gt;setTimeout&lt;/tt&gt; code for execution immediately after the current call stack closes. 
&lt;/li&gt;&lt;li&gt;This technique can be used to prioritize certain functionality such as showing and hiding loading indicator prior to executing a compurationally heavy operation such as modifying the DOM. 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;In a typical scenario this will not turn the loading indicator visible:
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;showLoadingIndicator&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt; doSomethingExpensive&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Workaround is to use setTimeout as follows (please take extra care when using this anti-pattern as what it does is actually delays the execution in order to display the loading indicator in the UI):
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; switchViews&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    setTimeout&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;        showLoadingIndicator&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; 0&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;    setTimeout&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;        doSomethingExpensive&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; 50&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Source: 
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://blog.thinkature.com/index.php/2006/11/26/escaping-the-javascript-call-stack-with-settimeout/&quot; class=&quot;external text&quot; title=&quot;http://blog.thinkature.com/index.php/2006/11/26/escaping-the-javascript-call-stack-with-settimeout/&quot; rel=&quot;nofollow&quot;&gt;Escaping the JavaScript call stack with setTimeout&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;a name=&quot;Styling&quot; id=&quot;Styling&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Styling &lt;/span&gt;&lt;/h2&gt;
&lt;a name=&quot;Optimize_CSS&quot; id=&quot;Optimize_CSS&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Optimize CSS &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Create a component library 
&lt;/li&gt;&lt;li&gt;Use consistent semantic styles 
&lt;/li&gt;&lt;li&gt;Design modules to be transparent on the inside 
&lt;/li&gt;&lt;li&gt;Be flexible 
&lt;/li&gt;&lt;li&gt;Learn to love grids 
&lt;/li&gt;&lt;li&gt;Minimize selectors 
&lt;/li&gt;&lt;li&gt;Separate structure and skin 
&lt;/li&gt;&lt;li&gt;Separate container and content 
&lt;/li&gt;&lt;li&gt;Extend objects by applying multiple classes to an element 
&lt;/li&gt;&lt;li&gt;Use reset and fonts from YUI 
&lt;/li&gt;&lt;li&gt;Source: &lt;a href=&quot;http://www.slideshare.net/stubbornella/object-oriented-css&quot; class=&quot;external text&quot; title=&quot;http://www.slideshare.net/stubbornella/object-oriented-css&quot; rel=&quot;nofollow&quot;&gt;Object Oriented CSS&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Change_CSS_classes_near_the_edges_of_the_DOM_tree&quot; id=&quot;Change_CSS_classes_near_the_edges_of_the_DOM_tree&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Change CSS classes near the edges of the DOM tree &lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;To limit the scope of the reflow to as few nodes as possible you should avoid changing a class on wrapper (or body) element(s) which affects the display of many child nodes. Additionally, that may result in re-resolving style on the entire document and for a large DOM that could lock up the browser for a while. 
&lt;/p&gt;&lt;p&gt;Source: 
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.shauninman.com/archive/2008/05/05/css_qualified_selectors#comment_3942&quot; class=&quot;external text&quot; title=&quot;http://www.shauninman.com/archive/2008/05/05/css_qualified_selectors#comment_3942&quot; rel=&quot;nofollow&quot;&gt;Dave Hyatt on CSS Selectors&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Avoid_tables_for_layout_or_use_table-layout:_fixed&quot; id=&quot;Avoid_tables_for_layout_or_use_table-layout:_fixed&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Avoid tables for layout or use table-layout: fixed&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;Avoid tables for layout. As if you needed another reason to avoid them, tables often require multiple passes before the layout is completely established because they are one of the rare cases where elements can affect the display of other elements that came before them on the DOM. Imagine a cell at the end of the table with very wide content that causes the column to be completely resized. This is why tables are not rendered progressively in all browsers and yet another reason why they are a bad idea for layout. 
&lt;/p&gt;&lt;p&gt;It is recommended to use a fixed layout ( table-layout: fixed) for data tables to allow a more efficient layout algorithm. This will allow the table to render row by row according to the CSS 2.1 specification. 
&lt;/p&gt;&lt;p&gt;Source:
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/&quot; class=&quot;external text&quot; title=&quot;http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/&quot; rel=&quot;nofollow&quot;&gt;Reflows &amp;amp; Repaints: CSS Performance making your JavaScript slow&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Optimize_images&quot; id=&quot;Optimize_images&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Optimize images &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Combine similar colors 
&lt;/li&gt;&lt;li&gt;Avoid whitespace in sprites, use CSS instead 
&lt;/li&gt;&lt;li&gt;Horizontal is better than vertical 
&lt;/li&gt;&lt;li&gt;Limit the number of colors 
&lt;/li&gt;&lt;li&gt;First optimize individual images, next sprites in it 
&lt;/li&gt;&lt;li&gt;Reduce anti-aliased pixels via size and alignment 
&lt;/li&gt;&lt;li&gt;Avoid diagonal gradients due to increased image size 
&lt;/li&gt;&lt;li&gt;Avoid alpha transparency (IE does not support) 
&lt;/li&gt;&lt;li&gt;Change gradient color every 2-3 pixels 
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Source: 
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Design Fast Websites &lt;a href=&quot;http://www.slideshare.net/stubbornella/designing-fast-websites-presentation&quot; class=&quot;external text&quot; title=&quot;http://www.slideshare.net/stubbornella/designing-fast-websites-presentation&quot; rel=&quot;nofollow&quot;&gt;slides&lt;/a&gt; and &lt;a href=&quot;http://video.yahoo.com/watch/4156174/11192533&quot; class=&quot;external text&quot; title=&quot;http://video.yahoo.com/watch/4156174/11192533&quot; rel=&quot;nofollow&quot;&gt;presentation&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;a name=&quot;S60_specifics&quot; id=&quot;S60_specifics&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;S60 specifics &lt;/span&gt;&lt;/h2&gt;
&lt;a name=&quot;Styling_2&quot; id=&quot;Styling_2&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Styling &lt;/span&gt;&lt;/h3&gt;
&lt;a name=&quot;Remove_borders_around_focusable_elements&quot; id=&quot;Remove_borders_around_focusable_elements&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Remove borders around focusable elements &lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;In WRT 1.x you can remove default blue borders in tab navigation mode with the following CSS. 
&lt;tt&gt;a:hover, a:focus { outline: none; }&lt;/tt&gt;
&lt;/p&gt;
&lt;a name=&quot;Fix_focus_problems_in_tabbed_navigation_mode&quot; id=&quot;Fix_focus_problems_in_tabbed_navigation_mode&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Fix focus problems in tabbed navigation mode &lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;In tabbed navigation mode the focus may lost while switching views. A fix to this issue is to place a read-only &lt;tt&gt;&amp;lt;input&amp;gt;&lt;/tt&gt; text element (can be absolutely positioned, zero-sized and transparent) under the element to be focused after switching the view and &lt;tt&gt;focus()&lt;/tt&gt;:ing on it after the view changes. 
&lt;/p&gt;
&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;/* CSS */&lt;br /&gt;#top {&lt;br /&gt;    position: absolute;&lt;br /&gt;    top: 0px;&lt;br /&gt;    width: 0px;&lt;br /&gt;    height: 0px;&lt;br /&gt;    border: 0px;&lt;br /&gt;    background: transparent;&lt;br /&gt;}&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- HTML --&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/input.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;input&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;top&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;readonly&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;readonly&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// JavaScript&lt;/span&gt;&lt;br /&gt;widget.&lt;span style=&quot;color: #660066;&quot;&gt;setNavigationEnabled&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// tabbed navigation mode&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; toggleViews&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    hideFirstView&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    showSecondView&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'top'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #000066;&quot;&gt;focus&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;You may need to alter the positioning of the element by modifying the &lt;tt&gt;top&lt;/tt&gt; property to position it underneath the first focusable element depending on your layout.
&lt;/p&gt;
&lt;a name=&quot;Prevent_elements_losing_focus_in_tabbed_navigation_mode&quot; id=&quot;Prevent_elements_losing_focus_in_tabbed_navigation_mode&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Prevent elements losing focus in tabbed navigation mode &lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;There is no exhaustive fix to this bug but it seems to help if you set the styles via onblur and onfocus event handlers instead of using CSS pseudo selector&amp;nbsp;:hover. 
&lt;/p&gt;&lt;p&gt;So instead of &lt;tt&gt;:hover&lt;/tt&gt; in CSS: 
&lt;/p&gt;
&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/style.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;style&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;#focusable:hover {&lt;br /&gt;    background-color: blue;&lt;br /&gt;}&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;a href=&quot;http://december.com/html/4/element/style.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;style&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/button.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;button&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;focusable&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;Foobar&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;a href=&quot;http://december.com/html/4/element/button.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;button&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;You utilize &lt;tt&gt;onfocus&lt;/tt&gt; and &lt;tt&gt;onblur&lt;/tt&gt; event handlers and set the styles using JavaScript: 
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'focusable'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #000066;&quot;&gt;onfocus&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;style&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;backgroundColor&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'blue'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'focusable'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #000066;&quot;&gt;onblur&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;style&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;backgroundColor&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'inherit'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/button.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;button&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;focusable&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;Foobar&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;a href=&quot;http://december.com/html/4/element/button.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;button&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Allow_animated_gif_images_to_animate_after_being_hidden&quot; id=&quot;Allow_animated_gif_images_to_animate_after_being_hidden&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Allow animated gif images to animate after being hidden &lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;S60 3.x and 5.0 devices do not animated gif images if they have been set as display: none at any point during their lifespan regardless of subsequent display value. A workaround to this bug is to avoid display: none and use position: absolute and alter left property to move the animated gif outside of the visible viewport to hide it ( left: -100%) and bring it back ( left: 0). 
&lt;/p&gt;&lt;p&gt;Alternatively you can fold the animated gif into another element whose style you set in a similar fashion. 
&lt;/p&gt;
&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- animation hidden --&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/img.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;img&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;style&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;position: absolute; left: -100%;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;animated.gif&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- animation visible --&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/img.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;img&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;style&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;position: absolute; left: 0;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;animated.gif&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Home_Screen_Widgets&quot; id=&quot;Home_Screen_Widgets&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Home Screen Widgets &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;Remove unneeded images in mini view 
&lt;ul&gt;&lt;li&gt;If images are used exclusively in full view, you can get rid of all of them (or selectively one by one) and save memory. 
&lt;/li&gt;&lt;li&gt;Any other unneeded images (e.g. images specific to screen orientation, portrait or landscape) can be also removed using similar technique. 
&lt;/li&gt;&lt;li&gt;To remove all images use: &lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; i &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;in&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;images&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    document.&lt;span style=&quot;color: #660066;&quot;&gt;images&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;src&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;#&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;ul&gt;&lt;li&gt;Remove unneeded nodes from the DOM when in mini view
&lt;ul&gt;&lt;li&gt;&lt;tt&gt;document.getElementById(&quot;fullview&quot;).innerHTML = &quot;&quot;;&lt;/tt&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;ul&gt;&lt;li&gt;Check and remove unused JavaScript functions and &amp;lt;embed&amp;gt; tags when in mini view
&lt;ul&gt;&lt;li&gt;Removing unused JavaScript functions and &amp;lt;embed&amp;gt; tags will save memory.
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;Consider using background color in mini view instead of images
&lt;/li&gt;&lt;li&gt;Respect onshow and onhide
&lt;ul&gt;&lt;li&gt;When you get an &lt;tt&gt;onhide&lt;/tt&gt; event, call &lt;tt&gt;clearInterval()&lt;/tt&gt; and &lt;tt&gt;clearTimeout()&lt;/tt&gt; for any pending timers and abort any pending XHR calls to keep the CPU usage low.
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;ul&gt;&lt;li&gt;Use setInterval wisely 
&lt;/li&gt;&lt;/ul&gt;
&lt;ul&gt;&lt;li&gt;Animations on Home Screen
&lt;ul&gt;&lt;li&gt;Avoid animations on home screen unless they are really needed for the sake of good user experience.
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Misc&quot; id=&quot;Misc&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Misc &lt;/span&gt;&lt;/h3&gt;
&lt;a name=&quot;Avoid_background-repeat_if_the_background-image_is_small_relative_to_its_containing_element&quot; id=&quot;Avoid_background-repeat_if_the_background-image_is_small_relative_to_its_containing_element&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Avoid background-repeat if the background-image is small relative to its containing element &lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;Interaction such as scrolling is extremely slow if background-repeat property is set to repeat-x or repeat-y combined with a background-image of a size which needs to be repeated multiple times to fill in the element's background. A workaround is to avoid using repeating backgrounds, that is use a big enough background-image with &lt;tt&gt;background-repeat: no-repeat&lt;/tt&gt;.
For example, a commonly used CSS design pattern -- which degrades the performance and should be avoided -- is to create a continuous vertical gradient background using a background image of width 1px which is repeated horizontally across the whole element width. 
&lt;/p&gt;&lt;p&gt;This optimization pattern is a trade off between the initial load time and the subsequent interaction smoothness. In a typical scenario using a bigger background-image (longed load time) with &lt;tt&gt;background-repeat: no-repeat&lt;/tt&gt; delivers a far superior overall UX over using a smaller repeating background. 
&lt;/p&gt;&lt;p&gt;Slow: 
&lt;/p&gt;
&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/style.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;style&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;.container {&lt;br /&gt;    width: 500px;&lt;br /&gt;    height: 50px;&lt;br /&gt;}&lt;br /&gt;.repeat {&lt;br /&gt;    background-image: url(background1.png); /* background1.png width 1px, height 50px */&lt;br /&gt;    background-repeat: repeat-x;&lt;br /&gt;}&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;a href=&quot;http://december.com/html/4/element/style.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;style&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/div.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;container repeat&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;Foobar&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;a href=&quot;http://december.com/html/4/element/div.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Faster: 
&lt;/p&gt;
&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/style.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;style&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;.container {&lt;br /&gt;    width: 500px;&lt;br /&gt;    height: 50px;&lt;br /&gt;}&lt;br /&gt;.norepeat {&lt;br /&gt;    background-image: url(background2.png); /* background2.png width 500px, height 50px */&lt;br /&gt;    background-repeat: no-repeat;&lt;br /&gt;}&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;a href=&quot;http://december.com/html/4/element/style.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;style&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/div.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;container norepeat&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;Foobar&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;a href=&quot;http://december.com/html/4/element/div.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;jQuery_Issues_and_Workarounds&quot; id=&quot;jQuery_Issues_and_Workarounds&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;jQuery Issues and Workarounds&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://crynobone.com/jquery-plugin-plainhtml/&quot; class=&quot;external text&quot; title=&quot;http://crynobone.com/jquery-plugin-plainhtml/&quot; rel=&quot;nofollow&quot;&gt;&lt;tt&gt;plainHtml()&lt;/tt&gt; plugin&lt;/a&gt; - a fix for html()
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;a name=&quot;jQuery-specifics&quot; id=&quot;jQuery-specifics&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;jQuery-specifics &lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;NB! These optimization patterns are aimed at jQuery 1.2.6. Recent versions and the Sizzle selector engine alleviate some of these bottlenecks. 
&lt;/p&gt;&lt;p&gt;Sources 
&lt;a href=&quot;http://ajaxian.com/archives/ajax-experience-talks-resig-slocum-and-heilmann&quot; class=&quot;external text&quot; title=&quot;http://ajaxian.com/archives/ajax-experience-talks-resig-slocum-and-heilmann&quot; rel=&quot;nofollow&quot;&gt;Advanced jQuery with John Resig &lt;/a&gt;
&lt;a href=&quot;http://ejohn.org/blog/function-call-profiling/&quot; class=&quot;external text&quot; title=&quot;http://ejohn.org/blog/function-call-profiling/&quot; rel=&quot;nofollow&quot;&gt;JavaScript Function Call Profiling &lt;/a&gt;
&lt;/p&gt;
&lt;a name=&quot;Minimize_the_use_of_slow_jQuery_methods&quot; id=&quot;Minimize_the_use_of_slow_jQuery_methods&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Minimize the use of slow jQuery methods &lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;&lt;tt&gt;remove()&lt;/tt&gt;, &lt;tt&gt;hmtl()&lt;/tt&gt; and &lt;tt&gt;empty()&lt;/tt&gt; have order of n2 time complexity, that is T(n) = O(n2). Minimizing the use of these methods is recommended in jQuery versions prior to 1.3.3. . 
&lt;/p&gt;
&lt;tt&gt;append, prepend, before, after&lt;/tt&gt; methods are expensive as well as taking a chunk of HTML and serializing it (&lt;tt&gt;$(&quot;&lt;div&gt;Hello World!&lt;/div&gt;&quot;)&lt;/tt&gt;). 
&lt;p&gt;The process behind these manipulations methods is the following: cleaning the input string, converting the string into a DOM fragment and injecting it into the DOM.
&lt;/p&gt;
&lt;a name=&quot;Optimize_selectors&quot; id=&quot;Optimize_selectors&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Optimize selectors &lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;Pay attention to the selectors you use. E.g. if you want to hide paragraphs which are direct children of div elements there are multiple ways to do it. 
&lt;/p&gt;&lt;p&gt;Using the selector below will try to find all div elements, loops thought all of them and find all p relative to the div, merge and figure out unique results. 
Making sure that the returned set is unique is where the most time is spent, and is very slow especially with a large DOM tree. 
&lt;/p&gt;&lt;p&gt;Slow: 
&lt;tt&gt;$(&quot;div p&quot;).hide();&lt;/tt&gt;
&lt;/p&gt;&lt;p&gt;A one way to optimize the selector is to match direct children of div (this may require you to re-factor the DOM structure of your app and may not be feasible in every scenario). 
This alternative flatter selector will try to find all div elements, loops thought all child elements and verifies if element is p. 
&lt;/p&gt;&lt;p&gt;Faster: 
&lt;tt&gt;$(&quot;div &amp;gt; p&quot;).hide();&lt;/tt&gt;
&lt;/p&gt;
&lt;a name=&quot;Consider_alternatives_to_jQuery.each.28.29&quot; id=&quot;Consider_alternatives_to_jQuery.each.28.29&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Consider alternatives to jQuery.each() &lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;Depending on the size of the array, looping through it using 
&lt;tt&gt;for (i = 0; i &amp;lt; len; i++) &lt;/tt&gt; instead of &lt;tt&gt;jQuery.each(myArray)&lt;/tt&gt; may be faster. 
see jQuery tests in &lt;a href=&quot;http://www.rockstarapps.com/samples/performance/&quot; class=&quot;external text&quot; title=&quot;http://www.rockstarapps.com/samples/performance/&quot; rel=&quot;nofollow&quot;&gt;Low Level JavaScript Performance&lt;/a&gt;
&lt;/p&gt;
&lt;a name=&quot;References&quot; id=&quot;References&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt; References &lt;/span&gt;&lt;/h2&gt;
&lt;a name=&quot;Generic&quot; id=&quot;Generic&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt; Generic &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt; &lt;a href=&quot;http://developer.yahoo.com/performance/rules.html&quot; class=&quot;external text&quot; title=&quot;http://developer.yahoo.com/performance/rules.html&quot; rel=&quot;nofollow&quot;&gt;Y! Best Practices for Speeding Up Your Web Site&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://dean.edwards.name/weblog/2007/08/js-compression/&quot; class=&quot;external text&quot; title=&quot;http://dean.edwards.name/weblog/2007/08/js-compression/&quot; rel=&quot;nofollow&quot;&gt;Notes on JS Compression&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://ajaxian.com/archives/steves-state-of-performance-2008&quot; class=&quot;external text&quot; title=&quot;http://ajaxian.com/archives/steves-state-of-performance-2008&quot; rel=&quot;nofollow&quot;&gt;Performance Roundup for 2008&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://cs193h.stevesouders.com/&quot; class=&quot;external text&quot; title=&quot;http://cs193h.stevesouders.com/&quot; rel=&quot;nofollow&quot;&gt;CS193H: High Performance Web Sites at Stanford&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://www.stevesouders.com/blog/2008/12/27/coupling-async-scripts/&quot; class=&quot;external text&quot; title=&quot;http://www.stevesouders.com/blog/2008/12/27/coupling-async-scripts/&quot; rel=&quot;nofollow&quot;&gt;Coupling Async Scripts&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://sites.google.com/site/io/even-faster-web-sites&quot; class=&quot;external text&quot; title=&quot;http://sites.google.com/site/io/even-faster-web-sites&quot; rel=&quot;nofollow&quot;&gt;Google I/O: Even Faster Web Sites&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://ajaxian.com/archives/ajax-experience-videos-performance-and-security&quot; class=&quot;external text&quot; title=&quot;http://ajaxian.com/archives/ajax-experience-videos-performance-and-security&quot; rel=&quot;nofollow&quot;&gt;Ajax Experience webcasts&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; Douglas Crockford
&lt;ul&gt;&lt;li&gt; &lt;a href=&quot;http://yuiblog.com/blog/2008/12/23/video-crockford-performance/&quot; class=&quot;external text&quot; title=&quot;http://yuiblog.com/blog/2008/12/23/video-crockford-performance/&quot; rel=&quot;nofollow&quot;&gt;Ajax Performance&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://video.yahoo.com/watch/111587/1027854&quot; class=&quot;external text&quot; title=&quot;http://video.yahoo.com/watch/111587/1027854&quot; rel=&quot;nofollow&quot;&gt;Advanced JavaScript - Performance&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://www.w3.org/TR/2008/WD-mwabp-20081222/&quot; class=&quot;external text&quot; title=&quot;http://www.w3.org/TR/2008/WD-mwabp-20081222/&quot; rel=&quot;nofollow&quot;&gt;Mobile Web Application Best Practices (W3C Working Draft)&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://javascriptrocks.com/performance/&quot; class=&quot;external text&quot; title=&quot;http://javascriptrocks.com/performance/&quot; rel=&quot;nofollow&quot;&gt;JavaScript Performance Rocks!&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://looksgoodworkswell.blogspot.com/2008/06/measuring-user-experience-performance.html&quot; class=&quot;external text&quot; title=&quot;http://looksgoodworkswell.blogspot.com/2008/06/measuring-user-experience-performance.html&quot; rel=&quot;nofollow&quot;&gt;Measuring User Experience Performance&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://thinkvitamin.com/features/webapps/serving-javascript-fast/&quot; class=&quot;external text&quot; title=&quot;http://thinkvitamin.com/features/webapps/serving-javascript-fast/&quot; rel=&quot;nofollow&quot;&gt;Serving JavaScript Fast&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://ajaxian.com/archives/some-more-javascript-performance-tips&quot; class=&quot;external text&quot; title=&quot;http://ajaxian.com/archives/some-more-javascript-performance-tips&quot; rel=&quot;nofollow&quot;&gt;JavaScript Performance Tips&lt;/a&gt; - generic, and Prototype-specific
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://www.sitepen.com/blog/2008/05/09/string-performance-an-analysis/&quot; class=&quot;external text&quot; title=&quot;http://www.sitepen.com/blog/2008/05/09/string-performance-an-analysis/&quot; rel=&quot;nofollow&quot;&gt;JavaScript String Performance Analysis&lt;/a&gt; - string concatenation with +=, join() and concat()
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://www.ibm.com/developerworks/web/library/wa-aj-perform/?ca=dgr-lnxw01FasterAjax&quot; class=&quot;external text&quot; title=&quot;http://www.ibm.com/developerworks/web/library/wa-aj-perform/?ca=dgr-lnxw01FasterAjax&quot; rel=&quot;nofollow&quot;&gt;IMB developerWorks Ajax Performance Analysis&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; Opera Developer Network
&lt;ul&gt;&lt;li&gt; &lt;a href=&quot;http://dev.opera.com/articles/view/efficient-javascript/&quot; class=&quot;external text&quot; title=&quot;http://dev.opera.com/articles/view/efficient-javascript/&quot; rel=&quot;nofollow&quot;&gt;Efficient JavaScript&lt;/a&gt; - Tips for ECMAScript, DOM and document loading
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://dev.opera.com/articles/view/cross-device-development-techniques-for/&quot; class=&quot;external text&quot; title=&quot;http://dev.opera.com/articles/view/cross-device-development-techniques-for/&quot; rel=&quot;nofollow&quot;&gt;Cross Device Development Techniques for Widgets&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://dev.opera.com/articles/view/javascript-best-practices/&quot; class=&quot;external text&quot; title=&quot;http://dev.opera.com/articles/view/javascript-best-practices/&quot; rel=&quot;nofollow&quot;&gt;JavaScript Best Practices&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://ejohn.org/blog/dom-documentfragments/&quot; class=&quot;external text&quot; title=&quot;http://ejohn.org/blog/dom-documentfragments/&quot; rel=&quot;nofollow&quot;&gt;DOM DocumentFragments&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; John Resig
&lt;ul&gt;&lt;li&gt; &lt;a href=&quot;http://ejohn.org/projects/javascript-engine-speeds/&quot; class=&quot;external text&quot; title=&quot;http://ejohn.org/projects/javascript-engine-speeds/&quot; rel=&quot;nofollow&quot;&gt;JavaScript Engine Speeds&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://ejohn.org/apps/speed/&quot; class=&quot;external text&quot; title=&quot;http://ejohn.org/apps/speed/&quot; rel=&quot;nofollow&quot;&gt;Benchmark&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://ejohn.org/blog/tags/speed/&quot; class=&quot;external text&quot; title=&quot;http://ejohn.org/blog/tags/speed/&quot; rel=&quot;nofollow&quot;&gt;getElementByClassName Speed Comparison&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://ejohn.org/blog/talk-performance-improvements-in-browsers/&quot; class=&quot;external text&quot; title=&quot;http://ejohn.org/blog/talk-performance-improvements-in-browsers/&quot; rel=&quot;nofollow&quot;&gt;Performance Improvements in Browsers&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://ejohn.org/blog/browser-paint-events&quot; class=&quot;external text&quot; title=&quot;http://ejohn.org/blog/browser-paint-events&quot; rel=&quot;nofollow&quot;&gt;Browser Paint Events&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://ejohn.org/blog/javascript-performance-stack/&quot; class=&quot;external text&quot; title=&quot;http://ejohn.org/blog/javascript-performance-stack/&quot; rel=&quot;nofollow&quot;&gt;JavaScript Performance Stack&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://ejohn.org/blog/native-json-support-is-required/&quot; class=&quot;external text&quot; title=&quot;http://ejohn.org/blog/native-json-support-is-required/&quot; rel=&quot;nofollow&quot;&gt;Native JSON Support is Required&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://schillmania.com/content/entries/2009/yahoo-photos-frontend-thoughts/&quot; class=&quot;external text&quot; title=&quot;http://schillmania.com/content/entries/2009/yahoo-photos-frontend-thoughts/&quot; rel=&quot;nofollow&quot;&gt;A Snapshot of The Yahoo! Photos Beta - Web Development Perspective&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://code.flickr.com/blog/2009/03/18/building-fast-client-side-searches/&quot; class=&quot;external text&quot; title=&quot;http://code.flickr.com/blog/2009/03/18/building-fast-client-side-searches/&quot; rel=&quot;nofollow&quot;&gt;Building Fast Client-side Searches&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://www.stevesouders.com/blog/2009/03/16/sxsw-slides/&quot; class=&quot;external text&quot; title=&quot;http://www.stevesouders.com/blog/2009/03/16/sxsw-slides/&quot; rel=&quot;nofollow&quot;&gt;Even Faster Websites - Steve Souders at SXSW ‘09&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/&quot; class=&quot;external text&quot; title=&quot;http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/&quot; rel=&quot;nofollow&quot;&gt;Reflows &amp;amp; Repaints: CSS Performance making your JavaScript slow?&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; Nicholas Zakas
&lt;ul&gt;&lt;li&gt; &lt;a href=&quot;http://www.nczonline.net/blog/2009/02/10/javascript-variable-performance/&quot; class=&quot;external text&quot; title=&quot;http://www.nczonline.net/blog/2009/02/10/javascript-variable-performance/&quot; rel=&quot;nofollow&quot;&gt;JavaScript Variable Performance&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://www.slideshare.net/nzakas/java-script-variable-performance-presentation&quot; class=&quot;external text&quot; title=&quot;http://www.slideshare.net/nzakas/java-script-variable-performance-presentation&quot; rel=&quot;nofollow&quot;&gt;slides&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; Speed Up Your JavaScript &lt;a href=&quot;http://www.nczonline.net/blog/2009/01/13/speed-up-your-javascript-part-1/&quot; class=&quot;external text&quot; title=&quot;http://www.nczonline.net/blog/2009/01/13/speed-up-your-javascript-part-1/&quot; rel=&quot;nofollow&quot;&gt;part 1&lt;/a&gt; &lt;a href=&quot;http://www.nczonline.net/blog/2009/01/20/speed-up-your-javascript-part-2/&quot; class=&quot;external text&quot; title=&quot;http://www.nczonline.net/blog/2009/01/20/speed-up-your-javascript-part-2/&quot; rel=&quot;nofollow&quot;&gt;part 2&lt;/a&gt;, &lt;a href=&quot;http://www.nczonline.net/blog/2009/01/27/speed-up-your-javascript-part-3/&quot; class=&quot;external text&quot; title=&quot;http://www.nczonline.net/blog/2009/01/27/speed-up-your-javascript-part-3/&quot; rel=&quot;nofollow&quot;&gt;part 3&lt;/a&gt; and &lt;a href=&quot;http://www.nczonline.net/blog/2009/02/03/speed-up-your-javascript-part-4/&quot; class=&quot;external text&quot; title=&quot;http://www.nczonline.net/blog/2009/02/03/speed-up-your-javascript-part-4/&quot; rel=&quot;nofollow&quot;&gt;part 4&lt;/a&gt;
&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.nczonline.net/blog/2009/05/19/javascript-stack-overflow-error/&quot; class=&quot;external text&quot; title=&quot;http://www.nczonline.net/blog/2009/05/19/javascript-stack-overflow-error/&quot; rel=&quot;nofollow&quot;&gt;JavaScript Stack Overflow Error&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt; Stoyan Stefanov
&lt;ul&gt;&lt;li&gt; &lt;a href=&quot;http://jsconf2009.com/stefanov_video.html&quot; class=&quot;external text&quot; title=&quot;http://jsconf2009.com/stefanov_video.html&quot; rel=&quot;nofollow&quot;&gt;High Performance Kick Ass Web Apps Video at JSCONF 2009&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt; Compatibility Tests
&lt;ul&gt;&lt;li&gt; &lt;a href=&quot;http://quirksmode.org/m/&quot; class=&quot;external text&quot; title=&quot;http://quirksmode.org/m/&quot; rel=&quot;nofollow&quot;&gt;Quirksmode.org Mobile Tests&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://code.google.com/speed/page-speed/docs/rules_intro.html&quot; class=&quot;external text&quot; title=&quot;http://code.google.com/speed/page-speed/docs/rules_intro.html&quot; rel=&quot;nofollow&quot;&gt;Google Page Speed&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://www.slideshare.net/madrobby/extreme-javascript-performance&quot; class=&quot;external text&quot; title=&quot;http://www.slideshare.net/madrobby/extreme-javascript-performance&quot; rel=&quot;nofollow&quot;&gt;Extreme JavaScript Performance&lt;/a&gt; by Thomas Fuchs
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;jQuery-specific&quot; id=&quot;jQuery-specific&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt; jQuery-specific &lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt; John Resig
&lt;ul&gt;&lt;li&gt; &lt;a href=&quot;http://ajaxian.com/archives/ajax-experience-talks-resig-slocum-and-heilmann&quot; class=&quot;external text&quot; title=&quot;http://ajaxian.com/archives/ajax-experience-talks-resig-slocum-and-heilmann&quot; rel=&quot;nofollow&quot;&gt;Advanced jQuery with John Resig&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://james.padolsey.com/javascript/extending-jquerys-selector-capabilities/&quot; class=&quot;external text&quot; title=&quot;http://james.padolsey.com/javascript/extending-jquerys-selector-capabilities/&quot; rel=&quot;nofollow&quot;&gt;Extending jQuery’s Selector Capabilities&lt;/a&gt;]
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://ejohn.org/blog/function-call-profiling/&quot; class=&quot;external text&quot; title=&quot;http://ejohn.org/blog/function-call-profiling/&quot; rel=&quot;nofollow&quot;&gt;JavaScript Function Call Profiling&lt;/a&gt; -&amp;nbsp;!FireUnit profiling extensions
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://stackoverflow.com/questions/400836/javascript-jquery-performance-measurement-and-best-practices-not-load-time&quot; class=&quot;external text&quot; title=&quot;http://stackoverflow.com/questions/400836/javascript-jquery-performance-measurement-and-best-practices-not-load-time&quot; rel=&quot;nofollow&quot;&gt;JavaScript (jQuery) performance measurement and best practices&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx&quot; class=&quot;external text&quot; title=&quot;http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx&quot; rel=&quot;nofollow&quot;&gt;Improve Your jQuery - 25 Tips&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://www.jedi.be/blog/2008/10/10/is-your-jquery-or-javascript-getting-slow-or-bad-performance/&quot; class=&quot;external text&quot; title=&quot;http://www.jedi.be/blog/2008/10/10/is-your-jquery-or-javascript-getting-slow-or-bad-performance/&quot; rel=&quot;nofollow&quot;&gt;jQuery Performance Tips&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://www.amazon.com/gp/blog/post/PLNK2A5VIHH7628EK&quot; class=&quot;external text&quot; title=&quot;http://www.amazon.com/gp/blog/post/PLNK2A5VIHH7628EK&quot; rel=&quot;nofollow&quot;&gt;43,439 reasons to use append() correctly&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://www.smashingmagazine.com/2008/09/16/jquery-examples-and-best-practices/&quot; class=&quot;external text&quot; title=&quot;http://www.smashingmagazine.com/2008/09/16/jquery-examples-and-best-practices/&quot; rel=&quot;nofollow&quot;&gt;jQuery and JavaScript Coding: Examples and Best Practices&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;This article is licensed under a &lt;a href=&quot;http://creativecommons.org/licenses/by-nc-sa/2.5/Creative&quot; class=&quot;external text&quot; title=&quot;http://creativecommons.org/licenses/by-nc-sa/2.5/Creative&quot; rel=&quot;nofollow&quot;&gt;Commons Attribution, Non Commercial - Share Alike 2.5 license&lt;/a&gt;.
&lt;/p&gt;</description>
			<pubDate>Wed, 25 Nov 2009 11:27:23 GMT</pubDate>			<dc:creator>Isalento</dc:creator>			<comments>http://wiki.forum.nokia.com/index.php/Talk:JavaScript_Performance_Best_Practices</comments>		</item>
		<item>
			<title>Using JSONP in WRT widget</title>
			<link>http://wiki.forum.nokia.com/index.php/Using_JSONP_in_WRT_widget</link>
			<description>&lt;p&gt;&lt;br /&gt;
&lt;b&gt;Moderator Note:- the Example link at the bottom does not appear to have had code loaded&lt;/b&gt;
&lt;/p&gt;
&lt;a name=&quot;JSONP&quot; id=&quot;JSONP&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;JSONP&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/JSONP&quot; class=&quot;external text&quot; title=&quot;http://en.wikipedia.org/wiki/JSONP&quot; rel=&quot;nofollow&quot;&gt;JSONP&lt;/a&gt; comes from the words &quot;&lt;a href=&quot;http://en.wikipedia.org/wiki/JSON&quot; class=&quot;external text&quot; title=&quot;http://en.wikipedia.org/wiki/JSON&quot; rel=&quot;nofollow&quot;&gt;JSON&lt;/a&gt; with padding&quot;. The padding word is there because the loaded JSON formatted data is wrapped inside a javascript function call. 
&lt;/p&gt;
&lt;a name=&quot;How_it_works&quot; id=&quot;How_it_works&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;How it works&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;JSONP utilizes dynamically created &lt;tt&gt;script&lt;/tt&gt; -tags. The benefit of  &lt;tt&gt;script&lt;/tt&gt; tag is that their source can point any domain. They are not restricted by same origin policy as AJAX requests. 
&lt;/p&gt;&lt;p&gt;Web APIs that use JSON data format usually let the end user to define callback function name by passing &lt;tt&gt;callback&lt;/tt&gt; argument as a part of web service query string. 
&lt;/p&gt;&lt;p&gt;The server generates a JSON formatted response and wraps it into a function call. The callback function is automatically called when JSON data is evaluated. 
&lt;/p&gt;&lt;p&gt;Example JSONP response:
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;handleTwitterData &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;results&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;..&lt;span style=&quot;color: #660066;&quot;&gt;json&lt;/span&gt; formatted data..&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;
Following example utilizes JSON version of the Twitter search API.
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;jsonpSearch&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;http://search.twitter.com/search.json&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;handleTwitterData&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;keyword&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; jsonpSearch&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;url&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; callback&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; keyword&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; head &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementsByTagName&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'head'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; scriptElement &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;createElement&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'script'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    scriptElement.&lt;span style=&quot;color: #660066;&quot;&gt;type&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    scriptElement.&lt;span style=&quot;color: #660066;&quot;&gt;src&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;  url&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;?callback=&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;callback&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;&amp;amp;q=&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;keyword&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    scriptElement.&lt;span style=&quot;color: #660066;&quot;&gt;id&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;jsonp&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    head&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;0&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;appendChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;scriptElement&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; handleTwitterData&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;data&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; tweets &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; data.&lt;span style=&quot;color: #660066;&quot;&gt;results&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    .....&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;If you are going to do multiple successive queries, you might end up situation where your widget leaks memory.  That's why it is important to delete both the script tag from the DOM and the JavaScript objects as well &lt;a href=&quot;http://neil.fraser.name/news/2009/07/27/&quot; class=&quot;external text&quot; title=&quot;http://neil.fraser.name/news/2009/07/27/&quot; rel=&quot;nofollow&quot;&gt;(1)&lt;/a&gt;.
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; clearOldSearch&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;    &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; script &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; document.&lt;span style=&quot;color: #660066;&quot;&gt;getElementById&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;jsonp&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;    &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;script&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;        script.&lt;span style=&quot;color: #660066;&quot;&gt;parentNode&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;removeChild&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;script&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;//does not really release the memory&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;        &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; property &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;in&lt;/span&gt; script&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;//so delete all the properties as well&lt;/span&gt;&lt;br /&gt;            &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;delete&lt;/span&gt; script&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;property&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;
For minimal test widget see: 
&lt;a href=&quot;http://www.forum.nokia.com/piazza/wiki/images/0/07/TwitterIn2min.zip&quot; class=&quot;external text&quot; title=&quot;http://www.forum.nokia.com/piazza/wiki/images/0/07/TwitterIn2min.zip&quot; rel=&quot;nofollow&quot;&gt;TwitterIn2Min.zip&lt;/a&gt;
&lt;/p&gt;
&lt;a name=&quot;Read_more_about_JSONP&quot; id=&quot;Read_more_about_JSONP&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Read more about JSONP&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;http://ajaxian.com/archives/jsonp-json-with-padding&quot; class=&quot;external text&quot; title=&quot;http://ajaxian.com/archives/jsonp-json-with-padding&quot; rel=&quot;nofollow&quot;&gt;Ajaxian JSONP: JSON With Padding&lt;/a&gt;
&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://neil.fraser.name/news/2009/07/27/&quot; class=&quot;external text&quot; title=&quot;http://neil.fraser.name/news/2009/07/27/&quot; rel=&quot;nofollow&quot;&gt;JSONP Memory Leak&lt;/a&gt;
&lt;/p&gt;</description>
			<pubDate>Wed, 25 Nov 2009 10:15:41 GMT</pubDate>			<dc:creator>Isalento</dc:creator>			<comments>http://wiki.forum.nokia.com/index.php/Talk:Using_JSONP_in_WRT_widget</comments>		</item>
		<item>
			<title>Creating a Slider Component for Guarana UI</title>
			<link>http://wiki.forum.nokia.com/index.php/Creating_a_Slider_Component_for_Guarana_UI</link>
			<description>&lt;p&gt;This article shows &lt;b&gt;how to create and use a Slider Component for the Guarana UI Library&lt;/b&gt;.
&lt;br /&gt;
&lt;a href=&quot;/index.php/File:Guarana_ui_slider.png&quot; class=&quot;image&quot; title=&quot;File:Guarana_ui_slider.png&quot;&gt;&lt;img alt=&quot;File:Guarana_ui_slider.png&quot; src=&quot;http://www.forum.nokia.com/piazza/wiki/images/5/5a/Guarana_ui_slider.png&quot; width=&quot;470&quot; height=&quot;347&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
&lt;br /&gt;
The Slider Component is visible on the &lt;b&gt;Guarana UI online Components Browser&lt;/b&gt;: &lt;a href=&quot;http://www.jappit.com/m/guaranabrowser/#guarana_slider&quot; class=&quot;external text&quot; title=&quot;http://www.jappit.com/m/guaranabrowser/#guarana_slider&quot; rel=&quot;nofollow&quot;&gt;Guarana UI Slider Component&lt;/a&gt;.
&lt;/p&gt;
&lt;table id=&quot;toc&quot; class=&quot;toc&quot; summary=&quot;Contents&quot;&gt;&lt;tr&gt;&lt;td&gt;&lt;div id=&quot;toctitle&quot;&gt;&lt;h2&gt;Contents&lt;/h2&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-1&quot;&gt;&lt;a href=&quot;#Introduction&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Introduction&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-1&quot;&gt;&lt;a href=&quot;#Building_the_empty_Component&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Building the empty Component&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-1&quot;&gt;&lt;a href=&quot;#Writing_the_Component&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Writing the Component&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-2&quot;&gt;&lt;a href=&quot;#Define_the_Component.27s_layout&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;3.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Define the Component's layout&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot;&gt;&lt;a href=&quot;#The_JavaScript_code&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;3.2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;The JavaScript code&lt;/span&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Initialization&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;3.2.1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Initialization&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#DOM_creation&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;3.2.2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;DOM creation&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Setting.2FGetting_Slider.27s_value&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;3.2.3&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Setting/Getting Slider's value&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot;&gt;&lt;a href=&quot;#Handling_events&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;3.2.4&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Handling events&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot;&gt;&lt;a href=&quot;#CSS_code&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;3.3&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;CSS code&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-1&quot;&gt;&lt;a href=&quot;#Using_the_Component&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;4&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Using the Component&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-1&quot;&gt;&lt;a href=&quot;#Finalizing_the_Component&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;5&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Finalizing the Component&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;script type=&quot;text/javascript&quot;&gt; if (window.showTocToggle) { var tocShowText = &quot;show&quot;; var tocHideText = &quot;hide&quot;; showTocToggle(); } &lt;/script&gt;
&lt;a name=&quot;Introduction&quot; id=&quot;Introduction&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Introduction&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;http://wiki.forum.nokia.com/index.php/Guarana_UI:_a_jQuery-Based_UI_Library_for_Nokia_WRT&quot; class=&quot;external text&quot; title=&quot;http://wiki.forum.nokia.com/index.php/Guarana_UI:_a_jQuery-Based_UI_Library_for_Nokia_WRT&quot; rel=&quot;nofollow&quot;&gt;Guarana UI Library&lt;/a&gt; is a &lt;b&gt;jQuery-Based UI Library for Nokia WRT&lt;/b&gt;, that provides a &lt;a href=&quot;http://wiki.forum.nokia.com/index.php/GuaranaUI-Documentation&quot; class=&quot;external text&quot; title=&quot;http://wiki.forum.nokia.com/index.php/GuaranaUI-Documentation&quot; rel=&quot;nofollow&quot;&gt;full set of Components&lt;/a&gt; ready to be used within Web Runtime widgets.
&lt;/p&gt;&lt;p&gt;Guarana UI also allows to &lt;a href=&quot;http://wiki.forum.nokia.com/index.php?title=How_to_create_a_new_Component_for_the_Guarana_UI_Library&quot; class=&quot;external text&quot; title=&quot;http://wiki.forum.nokia.com/index.php?title=How_to_create_a_new_Component_for_the_Guarana_UI_Library&quot; rel=&quot;nofollow&quot;&gt;build new UI Components&lt;/a&gt;, and integrate them with the Guarana UI structure. Before proceeding with this article, it is so necessary to view the general process behind the creation of a new Guarana UI Component, described here: &lt;a href=&quot;/index.php/How_to_create_a_new_Component_for_the_Guarana_UI_Library&quot; title=&quot;How to create a new Component for the Guarana UI Library&quot;&gt;How to create a new Component for the Guarana UI Library&lt;/a&gt;.
&lt;/p&gt;
&lt;a name=&quot;Building_the_empty_Component&quot; id=&quot;Building_the_empty_Component&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Building the empty Component&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;First thing to do, is to &lt;b&gt;create the Component skeleton&lt;/b&gt;. This process is described in the &lt;a href=&quot;http://wiki.forum.nokia.com/index.php/How_to_create_a_new_Component_for_the_Guarana_UI_Library#Setup_the_Component_source_files&quot; class=&quot;external text&quot; title=&quot;http://wiki.forum.nokia.com/index.php/How_to_create_a_new_Component_for_the_Guarana_UI_Library#Setup_the_Component_source_files&quot; rel=&quot;nofollow&quot;&gt;Setup the Component source files section&lt;/a&gt; of the &lt;a href=&quot;http://wiki.forum.nokia.com/index.php/How_to_create_a_new_Component_for_the_Guarana_UI_Library&quot; class=&quot;external text&quot; title=&quot;http://wiki.forum.nokia.com/index.php/How_to_create_a_new_Component_for_the_Guarana_UI_Library&quot; rel=&quot;nofollow&quot;&gt;How-to article&lt;/a&gt;.
&lt;/p&gt;&lt;p&gt;The following steps must be performed:
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt; &lt;b&gt;create an empty slider.js file&lt;/b&gt; in the &quot;&amp;lt;GUARANA_BASE_PATH&amp;gt;/src&quot; folder
&lt;/li&gt;&lt;li&gt; &lt;b&gt;create an empty slider.css file&lt;/b&gt; in the &quot;&amp;lt;GUARANA_BASE_PATH&amp;gt;/themes/nokia/base/&quot; folder
&lt;/li&gt;&lt;li&gt; add the &lt;b&gt;dependency declarations&lt;/b&gt; to both the &quot;&amp;lt;GUARANA_BASE_PATH&amp;gt;/src/defaults.js&quot; and &quot;&amp;lt;GUARANA_BASE_PATH&amp;gt;/build/build/js/defaults.js&quot; files
&lt;/li&gt;&lt;/ul&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;/*&lt;br /&gt; * Slider&lt;br /&gt; */&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'slider'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	getPath&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;return&lt;/span&gt; NOKIA_PATH_JAVASCRIPT &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'slider.js'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;	requires&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'widget'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'slider-css'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'slider-css'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	getPath&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;return&lt;/span&gt; NOKIA_PATH_STYLE_ROOT &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'slider.css'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;	type&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'css'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;	requires&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'base-css'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;ul&gt;&lt;li&gt; &lt;b&gt;launch the Guarana UI build process&lt;/b&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Now, the skeleton files are ready to be used, so it's possible to implement the new component.
&lt;/p&gt;
&lt;a name=&quot;Writing_the_Component&quot; id=&quot;Writing_the_Component&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Writing the Component&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;In order to write the component, let's &lt;b&gt;create an empty WRT project&lt;/b&gt;. First thing to do, is to move the &quot;&amp;lt;GUARANA_BASE_PATH&amp;gt;/build/Guarana/lib/&quot; and &quot;&amp;lt;GUARANA_BASE_PATH&amp;gt;/build/Guarana/themes/&quot; to the just created empty WRT project.
&lt;/p&gt;
&lt;a name=&quot;Define_the_Component.27s_layout&quot; id=&quot;Define_the_Component.27s_layout&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Define the Component's layout&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;The Slider component will have the following &lt;b&gt;look-and-feel&lt;/b&gt; (actually, the same of the &lt;a href=&quot;http://wiki.forum.nokia.com/index.php/Creating_a_Slider_component_for_Mobile_Web_Templates&quot; class=&quot;external text&quot; title=&quot;http://wiki.forum.nokia.com/index.php/Creating_a_Slider_component_for_Mobile_Web_Templates&quot; rel=&quot;nofollow&quot;&gt;Slider component for Mobile Web Templates&lt;/a&gt;):&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;/index.php/File:Mobilewebtemplates_slider_component.png&quot; class=&quot;image&quot; title=&quot;File:Mobilewebtemplates_slider_component.png&quot;&gt;&lt;img alt=&quot;File:Mobilewebtemplates_slider_component.png&quot; src=&quot;http://www.forum.nokia.com/piazza/wiki/images/e/ec/Mobilewebtemplates_slider_component.png&quot; width=&quot;380&quot; height=&quot;255&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
&lt;br /&gt;
Since this &lt;b&gt;component uses images&lt;/b&gt;, it is necessary to &lt;b&gt;place them in the right folder&lt;/b&gt;, in order for Guarana UI to correctly recognize them. Component's images must be placed inside the &lt;b&gt;&quot;themes/nokia/base/images/&quot; folder of the WRT project&lt;/b&gt;.
&lt;/p&gt;
&lt;a name=&quot;The_JavaScript_code&quot; id=&quot;The_JavaScript_code&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;The JavaScript code&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;This section shows and explains the Slider JavaScript code.
&lt;/p&gt;
&lt;a name=&quot;Initialization&quot; id=&quot;Initialization&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Initialization&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;The &lt;b&gt;most important&lt;/b&gt; part of the component, and the &lt;b&gt;first to be executed&lt;/b&gt;, is the &lt;b&gt;initialize() function&lt;/b&gt;. It must take care of initializing the Component's properties, by using default options when explicit ones are not used, and then of creating the slider:
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;initialize&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;options&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; instance &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; defaults &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;		minValue&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; 0&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;		maxValue&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; 100&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;		increment&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; 1&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;		value&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; 0&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;		readonly&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;        instance.&lt;span style=&quot;color: #660066;&quot;&gt;options&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; jQuery.&lt;span style=&quot;color: #660066;&quot;&gt;extend&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;defaults&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; options&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;        instance.&lt;span style=&quot;color: #660066;&quot;&gt;element&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; jQuery&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; instance.&lt;span style=&quot;color: #660066;&quot;&gt;options&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;element&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;        instance._super.&lt;span style=&quot;color: #660066;&quot;&gt;apply&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;instance&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;instance.&lt;span style=&quot;color: #660066;&quot;&gt;options&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;        instance.&lt;span style=&quot;color: #660066;&quot;&gt;registerData&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;slider&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;        instance._create&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	instance.&lt;span style=&quot;color: #660066;&quot;&gt;minValue&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; instance.&lt;span style=&quot;color: #660066;&quot;&gt;options&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;minValue&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	instance.&lt;span style=&quot;color: #660066;&quot;&gt;maxValue&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; instance.&lt;span style=&quot;color: #660066;&quot;&gt;options&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;maxValue&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	instance.&lt;span style=&quot;color: #660066;&quot;&gt;increment&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; instance.&lt;span style=&quot;color: #660066;&quot;&gt;options&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;increment&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;        instance.&lt;span style=&quot;color: #660066;&quot;&gt;setValue&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;instance.&lt;span style=&quot;color: #660066;&quot;&gt;options&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	instance.&lt;span style=&quot;color: #660066;&quot;&gt;registerVibrationOn&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	instance.&lt;span style=&quot;color: #660066;&quot;&gt;fireCallback&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'create'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;DOM_creation&quot; id=&quot;DOM_creation&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;DOM creation&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;The &lt;b&gt;_create() function takes care of creating the Slider DOM structure&lt;/b&gt;, binding the necessary events to make the Component fully interactive. Before defining the _create function, let's define which &lt;b&gt;CSS styles&lt;/b&gt; will be used by the Component, by using the Styles property:
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;Styles&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	slider&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'slider'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;	sliderItem&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'slider-item'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;	sliderValue&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'slider-value'&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Below, it is possible to see the _create function:
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;_create&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; instance &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; options &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; instance.&lt;span style=&quot;color: #660066;&quot;&gt;options&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; element &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; instance.&lt;span style=&quot;color: #660066;&quot;&gt;element&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; Styles &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; instance.&lt;span style=&quot;color: #660066;&quot;&gt;Styles&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	element.&lt;span style=&quot;color: #660066;&quot;&gt;each&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;i&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; el&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;		Nokia.&lt;span style=&quot;color: #660066;&quot;&gt;util&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;addClass&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;el&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; Styles.&lt;span style=&quot;color: #660066;&quot;&gt;slider&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	instance.&lt;span style=&quot;color: #660066;&quot;&gt;slider&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; Nokia.&lt;span style=&quot;color: #660066;&quot;&gt;dom&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;parseHTML&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'&amp;lt;div class=&amp;quot;'&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; Styles.&lt;span style=&quot;color: #660066;&quot;&gt;sliderItem&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	instance.&lt;span style=&quot;color: #660066;&quot;&gt;sliderItem&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; Nokia.&lt;span style=&quot;color: #660066;&quot;&gt;dom&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;parseHTML&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'&amp;lt;a href=&amp;quot;javascript:void(0)&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	instance.&lt;span style=&quot;color: #660066;&quot;&gt;sliderHandle&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; Nokia.&lt;span style=&quot;color: #660066;&quot;&gt;dom&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;parseHTML&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	instance.&lt;span style=&quot;color: #660066;&quot;&gt;sliderValue&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; Nokia.&lt;span style=&quot;color: #660066;&quot;&gt;dom&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;parseHTML&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'&amp;lt;div class=&amp;quot;'&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; Styles.&lt;span style=&quot;color: #660066;&quot;&gt;sliderValue&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;!&lt;/span&gt;options.&lt;span style=&quot;color: #660066;&quot;&gt;readonly&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;		&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; clickAction &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;			instance.&lt;span style=&quot;color: #660066;&quot;&gt;handleClicked&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;			&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;		&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;		&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; keyAction &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;			instance.&lt;span style=&quot;color: #660066;&quot;&gt;handleKeyDown&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;			&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;		&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;		instance.&lt;span style=&quot;color: #660066;&quot;&gt;sliderItem&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;bind&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'click.slider'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; clickAction&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;		instance.&lt;span style=&quot;color: #660066;&quot;&gt;sliderItem&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;bind&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'keypress.slider'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; keyAction&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	instance.&lt;span style=&quot;color: #660066;&quot;&gt;sliderItem&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;instance.&lt;span style=&quot;color: #660066;&quot;&gt;sliderHandle&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	instance.&lt;span style=&quot;color: #660066;&quot;&gt;slider&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;instance.&lt;span style=&quot;color: #660066;&quot;&gt;sliderItem&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	element.&lt;span style=&quot;color: #660066;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;instance.&lt;span style=&quot;color: #660066;&quot;&gt;slider&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	element.&lt;span style=&quot;color: #660066;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;instance.&lt;span style=&quot;color: #660066;&quot;&gt;sliderValue&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Setting.2FGetting_Slider.27s_value&quot; id=&quot;Setting.2FGetting_Slider.27s_value&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Setting/Getting Slider's value&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;Being fully interactive, the Component needs &lt;b&gt;functions that allow setting and getting the Slider's value&lt;/b&gt;. The setting function must also take care of &lt;b&gt;updating the Component's appearance&lt;/b&gt;, and this operation will be performed by the update() function in the code below:
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;update&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; positionX &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; 100 &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;value&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;minValue&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;maxValue&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;minValue&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;sliderHandle&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;css&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'background-position'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; positionX &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'% center'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;setValue&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;_value&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;sliderValue&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;_value&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;value&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; _value&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;update&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;getValue&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;_value&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Handling_events&quot; id=&quot;Handling_events&quot;&gt;&lt;/a&gt;&lt;h4&gt; &lt;span class=&quot;mw-headline&quot;&gt;Handling events&lt;/span&gt;&lt;/h4&gt;
&lt;p&gt;As the Component must be &lt;b&gt;usable with both touch and key-based navigation&lt;/b&gt;, it is necessary to define two different event handlers, that will handle a specific event. The handleKeyDown() function will handle the key-based events, while the handleClicked() function will handle the touch-based ones.
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;handleKeyDown&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; key &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; e.&lt;span style=&quot;color: #660066;&quot;&gt;keyCode&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; newValue &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;key &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; 37 &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;value&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;minValue&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;		newValue &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; Math.&lt;span style=&quot;color: #660066;&quot;&gt;max&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;minValue&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;value&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;increment&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;key &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; 39 &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;value&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;maxValue&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;		newValue &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; Math.&lt;span style=&quot;color: #660066;&quot;&gt;min&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;maxValue&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;value&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;increment&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;newValue &lt;span style=&quot;color: #339933;&quot;&gt;!=&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;		&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;setValue&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;newValue&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;		&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;fireCallback&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'change'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; e&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;handleClicked&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;e&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; mouseX &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; e.&lt;span style=&quot;color: #660066;&quot;&gt;clientX&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; relativeX &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; mouseX &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;sliderHandle&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;position&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;left&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; newValue &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;minValue&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; Math.&lt;span style=&quot;color: #660066;&quot;&gt;round&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;maxValue&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;minValue&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; relativeX &lt;span style=&quot;color: #339933;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;sliderHandle&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;width&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;increment&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;increment&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;setValue&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;newValue&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;	&lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;fireCallback&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'change'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; e&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;CSS_code&quot; id=&quot;CSS_code&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;CSS code&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;b&gt;CSS code, contained in the slider.css file&lt;/b&gt;, is the following one:
&lt;/p&gt;
&lt;pre class=&quot;css&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #6666ff;&quot;&gt;.slider&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;margin&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;padding&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;list-style&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;none&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #6666ff;&quot;&gt;.slider&lt;/span&gt; div&lt;span style=&quot;color: #6666ff;&quot;&gt;.slider-value&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;display&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;block&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;clear&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;both&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;text-align&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;center&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;font-weight&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;bold&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;margin-bottom&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;10px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #6666ff;&quot;&gt;.slider&lt;/span&gt; div&lt;span style=&quot;color: #6666ff;&quot;&gt;.slider-item&lt;/span&gt; &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;left&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;width&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt;%&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;margin-bottom&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;2px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;margin-top&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;10px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;line-height&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;40px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;background&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;images/sprite-button-rounded-right.png&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;no-repeat&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;right&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;top&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;text-align&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;center&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #6666ff;&quot;&gt;.slider&lt;/span&gt; div&lt;span style=&quot;color: #6666ff;&quot;&gt;.slider-item&lt;/span&gt;&lt;span style=&quot;color: #3333ff;&quot;&gt;:hover &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;background&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;images/sprite-button-rounded-right.png&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;no-repeat&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;right&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;bottom&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #6666ff;&quot;&gt;.slider&lt;/span&gt; div&lt;span style=&quot;color: #6666ff;&quot;&gt;.slider-item&lt;/span&gt; a &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;width&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt;%&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;display&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;block&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;padding&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; 0 &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;40px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;background&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;images/sprite-button-rounded-left.png&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;no-repeat&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;left&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;top&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;text-decoration&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;none&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #cc00cc;&quot;&gt;#333333&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #6666ff;&quot;&gt;.slider&lt;/span&gt; div&lt;span style=&quot;color: #6666ff;&quot;&gt;.slider-item&lt;/span&gt; a&lt;span style=&quot;color: #3333ff;&quot;&gt;:hover &lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;background&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;images/sprite-button-rounded-left.png&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;no-repeat&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;left&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;bottom&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #cc00cc;&quot;&gt;#FFF&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;outline&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;none&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #6666ff;&quot;&gt;.slider&lt;/span&gt; div&lt;span style=&quot;color: #6666ff;&quot;&gt;.slider-item&lt;/span&gt; a span &lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;margin-left&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;5px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;margin-right&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;5px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;display&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;block&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;height&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #933;&quot;&gt;40px&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;background-image&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;images/slider-off.png&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;background-repeat&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;no-repeat&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;background-position&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; 0 &lt;span style=&quot;color: #993333;&quot;&gt;center&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #6666ff;&quot;&gt;.slider&lt;/span&gt; div&lt;span style=&quot;color: #6666ff;&quot;&gt;.slider-item&lt;/span&gt; a&lt;span style=&quot;color: #3333ff;&quot;&gt;:hover &lt;/span&gt;span&lt;br /&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;	&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;background-image&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;images/slider-on.png&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #00AA00;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;a name=&quot;Using_the_Component&quot; id=&quot;Using_the_Component&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Using the Component&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;The Slider can be used by following these steps:
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt; &lt;b&gt;Include the Guarana UI CSS dependencies&lt;/b&gt; (as explained here: &lt;a href=&quot;/index.php/GuaranaUI-QuickStart&quot; title=&quot;GuaranaUI-QuickStart&quot;&gt;GuaranaUI-QuickStart&lt;/a&gt;):
&lt;/li&gt;&lt;/ul&gt;
&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Themeroller CSS --&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/link.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;link&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;themes/themeroller/default-theme/Themeroller.css&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;media&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;screen&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Specific Theme/Resolution CSS --&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/link.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;link&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;themes/nokia/ext-theme/default/360x640/custom.css&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;media&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;screen&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;ul&gt;&lt;li&gt; Include the &lt;b&gt;JavaScript dependencies&lt;/b&gt;:
&lt;/li&gt;&lt;/ul&gt;
&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- jQuery file --&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/script.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;script&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/lib/jquery/jQuery.js&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;charset&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;a href=&quot;http://december.com/html/4/element/script.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;script&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Guarana file --&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/script.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;script&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/lib/Guarana.js&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;charset&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;a href=&quot;http://december.com/html/4/element/script.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;script&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;ul&gt;&lt;li&gt; define a &lt;b&gt;root element&lt;/b&gt; in the widget's HTML code:
&lt;/li&gt;&lt;/ul&gt;
&lt;pre class=&quot;html4strict&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;lt;&lt;a href=&quot;http://december.com/html/4/element/div.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;slider01&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt;&lt;a href=&quot;http://december.com/html/4/element/div.html&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;div&lt;/span&gt;&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;ul&gt;&lt;li&gt; define the Guarana UI &lt;b&gt;path variables&lt;/b&gt;:
&lt;/li&gt;&lt;/ul&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;NOKIA_PATH_JAVASCRIPT &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'lib/'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;NOKIA_PATH_STYLE_ROOT &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'themes/nokia/base/'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;ul&gt;&lt;li&gt; use the &lt;b&gt;Nokia Loader&lt;/b&gt; to load the slider resources:
&lt;/li&gt;&lt;/ul&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;Nokia.&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;use&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'slider'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; init&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;ul&gt;&lt;li&gt; in the init() function, &lt;b&gt;initialize the Slider&lt;/b&gt;:
&lt;/li&gt;&lt;/ul&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; slider1 &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;new&lt;/span&gt; Nokia.&lt;span style=&quot;color: #660066;&quot;&gt;Slider&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    element&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;'#slider01'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    value&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; 40&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;	minValue&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; 0&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;	maxValue&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; 100&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;	increment&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; 5&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    create&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #000066;&quot;&gt;alert&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'slider created'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    change&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;event&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; value&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #000066;&quot;&gt;alert&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;'slider change'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Finalizing_the_Component&quot; id=&quot;Finalizing_the_Component&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Finalizing the Component&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;Once finished, some steps have to be performed:
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt; &lt;b&gt;move back the slider.js file&lt;/b&gt; to the &quot;&amp;lt;GUARANA_BASE_PATH&amp;gt;/src/&quot; folder
&lt;/li&gt;&lt;li&gt; &lt;b&gt;move back the slider.css file&lt;/b&gt; to the &quot;&amp;lt;GUARANA_BASE_PATH&amp;gt;/themes/nokia/base/&quot; folder
&lt;/li&gt;&lt;li&gt; &lt;b&gt;move the Component images&lt;/b&gt; to the &quot;&amp;lt;GUARANA_BASE_PATH&amp;gt;/themes/nokia/base/images/&quot; folder
&lt;/li&gt;&lt;li&gt; &lt;b&gt;launch the Guarana UI build process&lt;/b&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;
Done this, the Slider Component is ready to be used in all your WRT widgets.
&lt;/p&gt;</description>
			<pubDate>Tue, 24 Nov 2009 14:08:33 GMT</pubDate>			<dc:creator>Jappit</dc:creator>			<comments>http://wiki.forum.nokia.com/index.php/Talk:Creating_a_Slider_Component_for_Guarana_UI</comments>		</item>
		<item>
			<title>Customizing a Guarana UI busy indicator</title>
			<link>http://wiki.forum.nokia.com/index.php/Customizing_a_Guarana_UI_busy_indicator</link>
			<description>&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;table style=&quot;background:#eceff2&quot; width=&quot;660px&quot; border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;

&lt;tr&gt;
&lt;td&gt;&lt;b&gt;ID&lt;/b&gt; &lt;/td&gt;&lt;td&gt;&amp;nbsp;
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Creation date&lt;/b&gt; &lt;/td&gt;&lt;td&gt; November 24, 2009
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Platform&lt;/b&gt; &lt;/td&gt;&lt;td&gt;
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Tested on devices&lt;/b&gt; &lt;/td&gt;&lt;td&gt; Nokia N97
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Category&lt;/b&gt; &lt;/td&gt;&lt;td&gt; Web Runtime (WRT)
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Subcategory&lt;/b&gt; &lt;/td&gt;&lt;td&gt; Guarana UI, UI
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;table style=&quot;background:#eceff2&quot; width=&quot;660px&quot; border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;

&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Keywords (APIs, classes, methods, functions)&lt;/b&gt;:
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;a name=&quot;Overview&quot; id=&quot;Overview&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Overview&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;This code snippet demonstrates how to customize a Guarana UI busy indicator. You can download the component library from &lt;a href=&quot;http://wiki.forum.nokia.com/index.php/Guarana_UI:_a_jQuery-Based_UI_Library_for_Nokia_WRT&quot; class=&quot;external text&quot; title=&quot;http://wiki.forum.nokia.com/index.php/Guarana_UI:_a_jQuery-Based_UI_Library_for_Nokia_WRT&quot; rel=&quot;nofollow&quot;&gt;Forum Nokia&lt;/a&gt;. This snippet assumes that you are familiar with adding the busy indicator component on a web page. For more information about this, read the snippet &lt;a href=&quot;/index.php/Adding_a_Guarana_UI_busy_indicator_on_a_web_page&quot; title=&quot;Adding a Guarana UI busy indicator on a web page&quot;&gt;Adding a Guarana UI busy indicator on a web page&lt;/a&gt;.
&lt;/p&gt;&lt;p&gt;To replace the busy indicator with your own version, first create a GIF animation that you want to use. Free animations can be created and downloaded e.g. from the &lt;a href=&quot;http://www.ajaxload.info/&quot; class=&quot;external text&quot; title=&quot;http://www.ajaxload.info/&quot; rel=&quot;nofollow&quot;&gt;Ajaxload&lt;/a&gt; Web site. After that, replace the &lt;tt&gt;themes/nokia/base/images/busyindicator.gif&lt;/tt&gt; with your own animation. Lastly, customize the width and height of the busy indicator so that they correspond to the width and height of the new animation. For example:
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;window.&lt;span style=&quot;color: #660066;&quot;&gt;busyIndicator&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;new&lt;/span&gt; Nokia.&lt;span style=&quot;color: #660066;&quot;&gt;Busy&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    element&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;#busyIndicatorContainer&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    width&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; 126&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    height&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; 22&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;    autoOpen&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Postconditions&quot; id=&quot;Postconditions&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Postconditions&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;The default GIF animation of a busy indicator is replaced with own animation.
&lt;/p&gt;
&lt;a name=&quot;See_also&quot; id=&quot;See_also&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;See also&lt;/span&gt;&lt;/h2&gt;
&lt;ul&gt;&lt;li&gt; &lt;a href=&quot;/index.php/Adding_a_Guarana_UI_busy_indicator_on_a_web_page&quot; title=&quot;Adding a Guarana UI busy indicator on a web page&quot;&gt;Adding a Guarana UI busy indicator on a web page&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Supplementary_material&quot; id=&quot;Supplementary_material&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Supplementary material&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;This code snippet is part of the stub concept, which means that it has been patched on top of a template application in order to be more useful for developers. The version of the WRT stub application used as a template in this snippet is v1.2.
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt; The patched, executable application that can be used to test the features described in this snippet is available for download at &lt;a href=&quot;http://www.forum.nokia.com/piazza/wiki/images/0/05/Customizing_a_guarana_ui_busy.zip&quot; class=&quot;internal&quot; title=&quot;Customizing a guarana ui busy.zip&quot;&gt;Media:customizing_a_guarana_ui_busy.zip&lt;/a&gt;.
&lt;/li&gt;&lt;li&gt; You can view all the changes that are required to implement the above-mentioned features (compared to the &lt;a href=&quot;/index.php/Adding_a_Guarana_UI_busy_indicator_on_a_web_page&quot; title=&quot;Adding a Guarana UI busy indicator on a web page&quot;&gt;Adding a Guarana UI busy indicator on a web page&lt;/a&gt; snippet). The changes are provided in unified diff and colour-coded diff (HTML) formats in &lt;a href=&quot;http://www.forum.nokia.com/piazza/wiki/images/4/40/Customizing_a_guarana_ui_busy.diff.zip&quot; class=&quot;internal&quot; title=&quot;Customizing a guarana ui busy.diff.zip&quot;&gt;Media:customizing_a_guarana_ui_busy.diff.zip&lt;/a&gt;.
&lt;/li&gt;&lt;li&gt; For general information on applying the patch, see &lt;a href=&quot;/index.php/Using_Diffs&quot; title=&quot;Using Diffs&quot;&gt;Using Diffs&lt;/a&gt;.
&lt;/li&gt;&lt;li&gt; For unpatched stub applications, see &lt;a href=&quot;/index.php/Example_stub&quot; title=&quot;Example stub&quot;&gt;Example stub&lt;/a&gt;.
&lt;/li&gt;&lt;/ul&gt;
</description>
			<pubDate>Tue, 24 Nov 2009 10:21:15 GMT</pubDate>			<dc:creator>Tapla</dc:creator>			<comments>http://wiki.forum.nokia.com/index.php/Talk:Customizing_a_Guarana_UI_busy_indicator</comments>		</item>
		<item>
			<title>Installing Java apps and WRT widgets using sis files</title>
			<link>http://wiki.forum.nokia.com/index.php/Installing_Java_apps_and_WRT_widgets_using_sis_files</link>
			<description>&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;table id=&quot;toc&quot; class=&quot;toc&quot; summary=&quot;Contents&quot;&gt;&lt;tr&gt;&lt;td&gt;&lt;div id=&quot;toctitle&quot;&gt;&lt;h2&gt;Contents&lt;/h2&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li class=&quot;toclevel-1&quot;&gt;&lt;a href=&quot;#Introduction&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Introduction&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-1&quot;&gt;&lt;a href=&quot;#Benefits&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Benefits&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-1&quot;&gt;&lt;a href=&quot;#Prerequisites&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Prerequisites&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-1&quot;&gt;&lt;a href=&quot;#Testing_this_package&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;4&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Testing this package&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-1&quot;&gt;&lt;a href=&quot;#Customizing_the_installation_package&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;5&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Customizing the installation package&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-1&quot;&gt;&lt;a href=&quot;#Deploying_the_installation_package&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;6&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Deploying the installation package&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-1&quot;&gt;&lt;a href=&quot;#Questions_.2F_feedback&quot;&gt;&lt;span class=&quot;tocnumber&quot;&gt;7&lt;/span&gt; &lt;span class=&quot;toctext&quot;&gt;Questions / feedback&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;script type=&quot;text/javascript&quot;&gt; if (window.showTocToggle) { var tocShowText = &quot;show&quot;; var tocHideText = &quot;hide&quot;; showTocToggle(); } &lt;/script&gt;
&lt;a name=&quot;Introduction&quot; id=&quot;Introduction&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Introduction&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;This article introduces the &lt;b&gt;Software Installer&lt;/b&gt; package. It allows developers to install their &lt;a href=&quot;http://wiki.forum.nokia.com/index.php/Category:Java_ME&quot; class=&quot;external text&quot; title=&quot;http://wiki.forum.nokia.com/index.php/Category:Java_ME&quot; rel=&quot;nofollow&quot;&gt;Java ME&lt;/a&gt;, &lt;a href=&quot;http://wiki.forum.nokia.com/index.php/Category:Web_Runtime_(WRT)&quot; class=&quot;external text&quot; title=&quot;http://wiki.forum.nokia.com/index.php/Category:Web_Runtime_(WRT)&quot; rel=&quot;nofollow&quot;&gt;Web Runtime (WRT)&lt;/a&gt;, &lt;a href=&quot;http://wiki.forum.nokia.com/index.php/Category:S60&quot; class=&quot;external text&quot; title=&quot;http://wiki.forum.nokia.com/index.php/Category:S60&quot; rel=&quot;nofollow&quot;&gt;Symbian S60&lt;/a&gt; and  &lt;a href=&quot;http://wiki.forum.nokia.com/index.php/Category:Flash_Lite&quot; class=&quot;external text&quot; title=&quot;http://wiki.forum.nokia.com/index.php/Category:Flash_Lite&quot; rel=&quot;nofollow&quot;&gt;Flash Lite&lt;/a&gt; (packaged as .sis) applications and dependencies using a single .sis file. A Carbide.c++ project is provided, and developers will customize them for their own installation needs.
&lt;/p&gt;
&lt;a name=&quot;Benefits&quot; id=&quot;Benefits&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt;Benefits&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;Multiple applications can be installed at a single shot, along with dependent components such as: image files, music, videos, configuration files, native (C++) components and so on. For example, &lt;a href=&quot;http://wiki.forum.nokia.com/index.php/Category:Web_Runtime_(WRT)&quot; class=&quot;external text&quot; title=&quot;http://wiki.forum.nokia.com/index.php/Category:Web_Runtime_(WRT)&quot; rel=&quot;nofollow&quot;&gt;WRT Widgets&lt;/a&gt; can be installed along with the &lt;a href=&quot;/index.php/APIBridge_Web_Runtime_API&quot; title=&quot;APIBridge Web Runtime API&quot;&gt;APIBridge_Web_Runtime_API&lt;/a&gt; if they depend on it, making the user experience a lot better than when installing multiple components separately.
&lt;/p&gt;
&lt;a name=&quot;Prerequisites&quot; id=&quot;Prerequisites&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt; Prerequisites &lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;&lt;b&gt;Update: If you want to test a ready-made example to see what the user experience looks like, please download this package, unzip it and install the signed .sisx file to your phone:&lt;br /&gt;&lt;br /&gt; &lt;a href=&quot;/index.php/File:SoftwareInstaller_nokia.zip&quot; title=&quot;File:SoftwareInstaller nokia.zip&quot;&gt;File:SoftwareInstaller nokia.zip&lt;/a&gt;&lt;/b&gt;
&lt;/p&gt;&lt;p&gt;In order to use this package to customize your installations, you need to have installed:
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt; Some &lt;a href=&quot;http://www.forum.nokia.com/Tools_Docs_and_Code/Tools/Platforms/S60_Platform_SDKs/&quot; class=&quot;external text&quot; title=&quot;http://www.forum.nokia.com/Tools_Docs_and_Code/Tools/Platforms/S60_Platform_SDKs/&quot; rel=&quot;nofollow&quot;&gt;S60 SDK&lt;/a&gt;, &lt;a href=&quot;http://www.forum.nokia.com/info/sw.nokia.com/id/4a7149a5-95a5-4726-913a-3c6f21eb65a5/S60-SDK-0616-3.0-mr.html&quot; class=&quot;external text&quot; title=&quot;http://www.forum.nokia.com/info/sw.nokia.com/id/4a7149a5-95a5-4726-913a-3c6f21eb65a5/S60-SDK-0616-3.0-mr.html&quot; rel=&quot;nofollow&quot;&gt;3.0 MR&lt;/a&gt; or greater. This example was created with &lt;a href=&quot;http://www.forum.nokia.com/info/sw.nokia.com/id/ec866fab-4b76-49f6-b5a5-af0631419e9c/S60_All_in_One_SDKs.html&quot; class=&quot;external text&quot; title=&quot;http://www.forum.nokia.com/info/sw.nokia.com/id/ec866fab-4b76-49f6-b5a5-af0631419e9c/S60_All_in_One_SDKs.html&quot; rel=&quot;nofollow&quot;&gt;S60 5th Edition SDK&lt;/a&gt;.
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://www.forum.nokia.com/Tools_Docs_and_Code/Tools/Extensions/S60_Extensions_Plugins/&quot; class=&quot;external text&quot; title=&quot;http://www.forum.nokia.com/Tools_Docs_and_Code/Tools/Extensions/S60_Extensions_Plugins/&quot; rel=&quot;nofollow&quot;&gt;S60 SDK Extensions Plug-in pack&lt;/a&gt;.
&lt;/li&gt;&lt;li&gt; &lt;a href=&quot;http://www.forum.nokia.com/Tools_Docs_and_Code/Tools/IDEs/Carbide.c++/&quot; class=&quot;external text&quot; title=&quot;http://www.forum.nokia.com/Tools_Docs_and_Code/Tools/IDEs/Carbide.c++/&quot; rel=&quot;nofollow&quot;&gt;Carbide.c++ 2.0+&lt;/a&gt; is optional but helps getting the job done more quickly.
&lt;/li&gt;&lt;li&gt; &lt;b&gt;Software Installer&lt;/b&gt; project in Zip format: &lt;a href=&quot;/index.php/File:SoftwareInstaller_24112009.zip&quot; title=&quot;File:SoftwareInstaller 24112009.zip&quot;&gt;File:SoftwareInstaller 24112009.zip&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Testing_this_package&quot; id=&quot;Testing_this_package&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt; Testing this package &lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;First thing is to do a test build to make sure the environment is set up correctly:
&lt;/p&gt;
&lt;ol&gt;&lt;li&gt; Install the SDKs and the Extensions Plug-in Pack listed above, if you still haven't done so.
&lt;/li&gt;&lt;li&gt; Extract the attached &lt;b&gt;SoftwareInstaller.zip&lt;/b&gt; package anywhere in your computer. In this example, the folder generated is &lt;b&gt;C:\temp\SoftwareInstaller&lt;/b&gt;
&lt;/li&gt;&lt;li&gt; Open a Windows Command Prompt, and cd into the project folder.
&lt;/li&gt;&lt;li&gt; Cd into &lt;b&gt;group&lt;/b&gt; folder and type &lt;pre class=&quot;text&quot; style=&quot;font-family:monospace;&quot;&gt;bldmake bldfiles&lt;/pre&gt; to create the build files.
&lt;/li&gt;&lt;li&gt; Type &lt;pre class=&quot;text&quot; style=&quot;font-family:monospace;&quot;&gt;abld build gcce&lt;/pre&gt;. This will build the package for the GCCE target, meant to be used in real hardware.
&lt;/li&gt;&lt;li&gt; Cd into &lt;b&gt;..\sis&lt;/b&gt; folder. 
&lt;/li&gt;&lt;li&gt; Type &lt;pre class=&quot;text&quot; style=&quot;font-family:monospace;&quot;&gt;makesis SoftwareInstaller_EKA2.pkg SoftwareInstaller.sis&lt;/pre&gt;. This will generate an unsigned .sis file. You will now need to sign the file so it works on your phone.
&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;br /&gt;If you do not own a &lt;a href=&quot;/index.php/Developer_certificate&quot; title=&quot;Developer certificate&quot;&gt;Developer certificate&lt;/a&gt;:
&lt;/p&gt;
&lt;ol&gt;&lt;li&gt; Go to &lt;a href=&quot;http://www.symbiansigned.com&quot; class=&quot;external text&quot; title=&quot;http://www.symbiansigned.com&quot; rel=&quot;nofollow&quot;&gt;Symbian Signed web site&lt;/a&gt; and choose the &lt;b&gt;Open Signed Online&lt;/b&gt; option. Fill out the &lt;b&gt;IMEI&lt;/b&gt;, &lt;b&gt;E-mail&lt;/b&gt; and &lt;b&gt;Application&lt;/b&gt; fields. You will receive a confirmation on your e-mail.
&lt;/li&gt;&lt;li&gt; Check your e-mail for the confirmation message. Click on the link provided. 
&lt;/li&gt;&lt;li&gt; Refresh your e-mail a couple of minutes later; you will have a link to download the signed &lt;b&gt;SoftwareInstaller.sis&lt;/b&gt; file.
&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;br /&gt;
If you have a &lt;a href=&quot;/index.php/Developer_certificate&quot; title=&quot;Developer certificate&quot;&gt;Developer certificate&lt;/a&gt;:
&lt;/p&gt;
&lt;ol&gt;&lt;li&gt; Sign the &lt;b&gt;SoftwareInstaller.sis&lt;/b&gt; file with your certificate and key.
&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;br /&gt;
Now you can install the signed &lt;b&gt;SoftwareInstaller.sis&lt;/b&gt; file on your phone. The S60 installer will prompt you about the file being a development-version application, then will install itself. A couple of seconds after the installation of the main package is completed, you will be prompted for the installation of the &lt;a href=&quot;http://library.forum.nokia.com/index.jsp?topic=/Web_Developers_Library/GUID-DEF30D00-8424-4122-9456-1245051EDF28.html&quot; class=&quot;external text&quot; title=&quot;http://library.forum.nokia.com/index.jsp?topic=/Web_Developers_Library/GUID-DEF30D00-8424-4122-9456-1245051EDF28.html&quot; rel=&quot;nofollow&quot;&gt;STEW widget&lt;/a&gt; (example from Forum Nokia Developer's Library). After the installation of &lt;b&gt;STEW&lt;/b&gt; is finished, the &lt;b&gt;MyTestApp&lt;/b&gt; Java MIDlet will be installed. 
&lt;/p&gt;&lt;p&gt;After these two applications are installed, you can use them from the Application folder and check they work correctly. Both have been installed by a single .sis file. Here is a visual summary of the installation experience on the phone:
&lt;/p&gt;
&lt;table class=&quot;gallery&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;
	&lt;caption&gt;Installation of multiple apps with a single .sis file&lt;/caption&gt;
	&lt;tr&gt;
		&lt;td&gt;&lt;div class=&quot;gallerybox&quot; style=&quot;width: 215px;&quot;&gt;
			&lt;div class=&quot;thumb&quot; style=&quot;padding: 38px 0; width: 210px;&quot;&gt;&lt;div style=&quot;margin-left: auto; margin-right: auto; width: 180px;&quot;&gt;&lt;a href=&quot;/index.php/File:SI_1.jpg&quot; class=&quot;image&quot; title=&quot;SI 1.jpg&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://www.forum.nokia.com/piazza/wiki/images/thumb/2/24/SI_1.jpg/180px-SI_1.jpg&quot; width=&quot;180&quot; height=&quot;320&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;
			&lt;div class=&quot;gallerytext&quot;&gt;
&lt;p&gt;SoftwareInstaller.sis in the Inbox
&lt;/p&gt;
			&lt;/div&gt;
		&lt;/div&gt;&lt;/td&gt;
		&lt;td&gt;&lt;div class=&quot;gallerybox&quot; style=&quot;width: 215px;&quot;&gt;
			&lt;div class=&quot;thumb&quot; style=&quot;padding: 38px 0; width: 210px;&quot;&gt;&lt;div style=&quot;margin-left: auto; margin-right: auto; width: 180px;&quot;&gt;&lt;a href=&quot;/index.php/File:SI_2.jpg&quot; class=&quot;image&quot; title=&quot;SI 2.jpg&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://www.forum.nokia.com/piazza/wiki/images/thumb/2/29/SI_2.jpg/180px-SI_2.jpg&quot; width=&quot;180&quot; height=&quot;320&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;
			&lt;div class=&quot;gallerytext&quot;&gt;
&lt;p&gt;Installation of the main package
&lt;/p&gt;
			&lt;/div&gt;
		&lt;/div&gt;&lt;/td&gt;
		&lt;td&gt;&lt;div class=&quot;gallerybox&quot; style=&quot;width: 215px;&quot;&gt;
			&lt;div class=&quot;thumb&quot; style=&quot;padding: 38px 0; width: 210px;&quot;&gt;&lt;div style=&quot;margin-left: auto; margin-right: auto; width: 180px;&quot;&gt;&lt;a href=&quot;/index.php/File:SI_3.jpg&quot; class=&quot;image&quot; title=&quot;SI 3.jpg&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://www.forum.nokia.com/piazza/wiki/images/thumb/b/bc/SI_3.jpg/180px-SI_3.jpg&quot; width=&quot;180&quot; height=&quot;320&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;
			&lt;div class=&quot;gallerytext&quot;&gt;
&lt;p&gt;Signing with a developer certificate prompts the user
&lt;/p&gt;
			&lt;/div&gt;
		&lt;/div&gt;&lt;/td&gt;
		&lt;td&gt;&lt;div class=&quot;gallerybox&quot; style=&quot;width: 215px;&quot;&gt;
			&lt;div class=&quot;thumb&quot; style=&quot;padding: 38px 0; width: 210px;&quot;&gt;&lt;div style=&quot;margin-left: auto; margin-right: auto; width: 180px;&quot;&gt;&lt;a href=&quot;/index.php/File:SI_4.jpg&quot; class=&quot;image&quot; title=&quot;SI 4.jpg&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://www.forum.nokia.com/piazza/wiki/images/thumb/c/c4/SI_4.jpg/180px-SI_4.jpg&quot; width=&quot;180&quot; height=&quot;320&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;
			&lt;div class=&quot;gallerytext&quot;&gt;
&lt;p&gt;Installation of the STEW widget
&lt;/p&gt;
			&lt;/div&gt;
		&lt;/div&gt;&lt;/td&gt;
		&lt;td&gt;&lt;div class=&quot;gallerybox&quot; style=&quot;width: 215px;&quot;&gt;
			&lt;div class=&quot;thumb&quot; style=&quot;padding: 38px 0; width: 210px;&quot;&gt;&lt;div style=&quot;margin-left: auto; margin-right: auto; width: 180px;&quot;&gt;&lt;a href=&quot;/index.php/File:SI_5.jpg&quot; class=&quot;image&quot; title=&quot;SI 5.jpg&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://www.forum.nokia.com/piazza/wiki/images/thumb/9/98/SI_5.jpg/180px-SI_5.jpg&quot; width=&quot;180&quot; height=&quot;320&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;
			&lt;div class=&quot;gallerytext&quot;&gt;
&lt;p&gt;Installation of the MyTestApp MIDlet
&lt;/p&gt;
			&lt;/div&gt;
		&lt;/div&gt;&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td&gt;&lt;div class=&quot;gallerybox&quot; style=&quot;width: 215px;&quot;&gt;
			&lt;div class=&quot;thumb&quot; style=&quot;padding: 38px 0; width: 210px;&quot;&gt;&lt;div style=&quot;margin-left: auto; margin-right: auto; width: 180px;&quot;&gt;&lt;a href=&quot;/index.php/File:SI_6.jpg&quot; class=&quot;image&quot; title=&quot;SI 6.jpg&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://www.forum.nokia.com/piazza/wiki/images/thumb/2/2e/SI_6.jpg/180px-SI_6.jpg&quot; width=&quot;180&quot; height=&quot;320&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;
			&lt;div class=&quot;gallerytext&quot;&gt;
&lt;p&gt;MIDlet installation complete
&lt;/p&gt;
			&lt;/div&gt;
		&lt;/div&gt;&lt;/td&gt;
		&lt;td&gt;&lt;div class=&quot;gallerybox&quot; style=&quot;width: 215px;&quot;&gt;
			&lt;div class=&quot;thumb&quot; style=&quot;padding: 38px 0; width: 210px;&quot;&gt;&lt;div style=&quot;margin-left: auto; margin-right: auto; width: 180px;&quot;&gt;&lt;a href=&quot;/index.php/File:SI_7.jpg&quot; class=&quot;image&quot; title=&quot;SI 7.jpg&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;http://www.forum.nokia.com/piazza/wiki/images/thumb/d/d4/SI_7.jpg/180px-SI_7.jpg&quot; width=&quot;180&quot; height=&quot;320&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;
			&lt;div class=&quot;gallerytext&quot;&gt;
&lt;p&gt;STEW widget and HelloMIDlet (MyTestApp) installed and ready to be used
&lt;/p&gt;
			&lt;/div&gt;
		&lt;/div&gt;&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;Next we'll see how you can customize this package to suit your application installation needs.
&lt;/p&gt;
&lt;a name=&quot;Customizing_the_installation_package&quot; id=&quot;Customizing_the_installation_package&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt; Customizing the installation package &lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;The first thing you need to know is that this is not simply a .sis file. There's a small executable (&quot;&lt;b&gt;SoftwareInstaller.exe&lt;/b&gt;&quot;) that does the job of installing all components whose files are in the &lt;b&gt;data&lt;/b&gt; folder and whose names are in the &lt;b&gt;data\WidgetInstFile&lt;/b&gt; file. This has implications in what you, the developer, must do to customize this package. 
&lt;/p&gt;&lt;p&gt;At a first glance, it would be easy to add your component to the &lt;b&gt;data&lt;/b&gt; folder and add its name to &lt;b&gt;WidgetInstFile&lt;/b&gt;. However, this is not an ordinary .sis file, but an actual Symbian C++ application. In the Symbian environment, all applications must have a valid, unique ID (&lt;b&gt;UID&lt;/b&gt;) and a unique executable file name, to avoid collision with other applications installed on the phone. Therefore you need to implement those changes before using this package, in order to install your applications in a production environment. To achieve this, you need to:
&lt;/p&gt;
&lt;ol&gt;&lt;li&gt; Go to the Symbian Signed website, and get a valid UID for your application. It will be in the format 0x12345678. Please notice that the example package comes with a UID of the test range (0xExxxxxxx) which must not be used for production applications. You will need a valid one or you will have problems with application collision and it will be impossible to sign them.
&lt;/li&gt;&lt;li&gt; After you have the valid UID, open the &lt;b&gt;SoftwareInstaller.mmp&lt;/b&gt; (&lt;b&gt;group&lt;/b&gt; folder) file and change the line &lt;pre class=&quot;text&quot; style=&quot;font-family:monospace;&quot;&gt;UID			 0 0xEDC63187&lt;/pre&gt; to &lt;pre class=&quot;text&quot; style=&quot;font-family:monospace;&quot;&gt;UID			 0 0x2xxxxxxx&lt;/pre&gt; where &lt;b&gt;0x2xxxxxxx&lt;/b&gt; is the UID you've received from Symbian Signed. Modify the &lt;b&gt;TARGET&lt;/b&gt; parameter to something like &lt;b&gt;MyApplicationName_0x2xxxxxxx.exe&lt;/b&gt;, again where &lt;b&gt;0x2xxxxxxx&lt;/b&gt; is your UID. This will ensure the file name for your executable is unique in the phone. Save and close the file.
&lt;/li&gt;&lt;li&gt; Open the &lt;b&gt;..\sis\SoftwareInstaller_EKA2.pkg&lt;/b&gt; file. Look for the line: &lt;pre class=&quot;text&quot; style=&quot;font-family:monospace;&quot;&gt;#{&amp;quot;SoftwareInstaller EXE&amp;quot;},(0xEDC63187),1,0,0&lt;/pre&gt; and change it to &lt;pre class=&quot;text&quot; style=&quot;font-family:monospace;&quot;&gt;#{&amp;quot;MyApplicationNAme&amp;quot;},(0x2xxxxxxx),1,0,0&lt;/pre&gt; where &lt;b&gt;MyApplicationName&lt;/b&gt; is, unsurprisingly, your application's name, and &lt;b&gt;0x2xxxxxxx&lt;/b&gt; is the same UID you used in the &lt;b&gt;.mmp&lt;/b&gt; file. You can also change the &lt;b&gt;Vendor&lt;/b&gt; section to reflect your company's name. 
&lt;/li&gt;&lt;li&gt; Look for the line &lt;pre class=&quot;text&quot; style=&quot;font-family:monospace;&quot;&gt;&amp;quot;\S60\devices\S60_5th_Edition_SDK_v1.0\Epoc32\release\gcce\urel\SoftwareInstaller.exe&amp;quot; - &amp;quot;!:\sys\bin\SoftwareInstaller.exe&amp;quot;, FR, RI&lt;/pre&gt; and change the name of &lt;b&gt;SoftwareInstaller.exe&lt;/b&gt; in both sides to the same name you've defined in step 2 of this section (&quot;&lt;b&gt;MyApplicationName_0x2xxxxxxx.exe&lt;/b&gt;&quot;). 
&lt;/li&gt;&lt;li&gt; Copy your applications to the &lt;b&gt;data&lt;/b&gt; folder. In this example, our apps are &lt;b&gt;stew.wgz&lt;/b&gt; and &lt;b&gt;MyTestApp&lt;/b&gt;, which is a Java ME application consisting of the JAD and JAR files. Make sure you copy ALL the installation files to the &lt;b&gt;data&lt;/b&gt; folder.
&lt;/li&gt;&lt;li&gt; Edit &lt;b&gt;..\data\WidgetInstFile&lt;/b&gt; (Notepad or Wordpad) and add the file names of the applications you want to install. In this example, we are adding &lt;b&gt;stew.wgz&lt;/b&gt; and &lt;b&gt;MyTestApp.jad&lt;/b&gt;. &lt;b&gt;Please note that, for Java ME apps, you can enter either the JAD or the JAR file name, but not both. If you are using JAD properties, or your MIDlet is signed, you must use the JAD file name, otherwise your MIDlet will not be installed correctly. &lt;/b&gt;Also note that &lt;b&gt;WidgetInstFile&lt;/b&gt; is not an ASCII file. Therefore you must use either Wordpad or Notepad (on Windows) and save the file as &lt;b&gt;Unicode, not as regular text&lt;/b&gt;. Save and close the file.
&lt;/li&gt;&lt;li&gt; Now you need to tell the package creator to add your files to the final .sis package. Open &lt;b&gt;..\sis\SoftwareInstaller_EKA2.pkg&lt;/b&gt; file and look for the lines: &lt;pre class=&quot;text&quot; style=&quot;font-family:monospace;&quot;&gt;;Files to be installed	&lt;br /&gt;&amp;quot;..\data\stew.wgz&amp;quot;	- &amp;quot;d:\WidgetInstaller\stew.wgz&amp;quot;&lt;br /&gt;&amp;quot;..\data\MyTestApp.jad&amp;quot;  - &amp;quot;d:\WidgetInstaller\MyTestApp.jad&amp;quot;&lt;br /&gt;&amp;quot;..\data\MyTestApp.jar&amp;quot;  - &amp;quot;d:\WidgetInstaller\MyTestApp.jar&amp;quot;&lt;/pre&gt;These directives will copy files &lt;b&gt;stew.wgz&lt;/b&gt;, &lt;b&gt;MyTestApp.jad&lt;/b&gt; and &lt;b&gt;MyTestApp.jar&lt;/b&gt; from your HD disk to the .sis file. If you fail to add these lines, nothing will be installed. Add your files here as needed. On the left side of the hyphen (&quot;-&quot;) you add the path to the file on your disk; on the right side you add the path on your phone's disk. Note that the latter must always be &quot;d:\WidgetInstaller\&quot;, otherwise the installer app won't find it.
&lt;/li&gt;&lt;li&gt; Now you are ready to rebuild the package. Change to the &lt;b&gt;group&quot; folder&lt;/b&gt;, type &lt;pre class=&quot;text&quot; style=&quot;font-family:monospace;&quot;&gt;abld reallyclean gcce&lt;/pre&gt; then &lt;pre class=&quot;text&quot; style=&quot;font-family:monospace;&quot;&gt;abld build gcce&lt;/pre&gt;
&lt;/li&gt;&lt;li&gt; Create the package using &lt;b&gt;makesis&lt;/b&gt; as described in the previous section. 
&lt;/li&gt;&lt;li&gt; Sign the package using either Symbian Signed Open Signed Online or your developer certificate. 
&lt;/li&gt;&lt;li&gt; You are then ready to test the package on your phone.
&lt;/li&gt;&lt;li&gt; &lt;b&gt;ATTENTION&lt;/b&gt;: At this point you may receive an &quot;Update error&quot; when installing your newly-created package on the phone. This happens because you've changed the UID of the package but kept some of the files that the old package (the one installed on the phone) was also using. To solve this error, you can either remove the previous package prior to installing the new one, or remove conflicting files, which will most likely be the ones from the &lt;b&gt;data&lt;/b&gt; folder. This will not happen in production since it's very unlikely that you are installing exactly the same file as any other package in the world with a different UID.
&lt;/li&gt;&lt;/ol&gt;
&lt;a name=&quot;Deploying_the_installation_package&quot; id=&quot;Deploying_the_installation_package&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt; Deploying the installation package &lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;In order to deploy the installation package to all your users, you need to sign the application with a real certificate. For that you will need to go to Symbian Signed and sign the application. You can use Express Signed since the app doesn't require any Manufacturer-granted capabilities. For an overview of the Symbian Signed process for production applications  &lt;a href=&quot;/index.php/Step_by_Step_instructions_to_Express_signing&quot; title=&quot;Step by Step instructions to Express signing&quot;&gt;Step by Step instructions to Express signing&lt;/a&gt;.
&lt;/p&gt;
&lt;a name=&quot;Questions_.2F_feedback&quot; id=&quot;Questions_.2F_feedback&quot;&gt;&lt;/a&gt;&lt;h3&gt; &lt;span class=&quot;mw-headline&quot;&gt; Questions / feedback &lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;Questions or feedback can be posted as comments to this page.
&lt;/p&gt;&lt;p&gt;Daniel Rocha&lt;br /&gt;
Forum Nokia
&lt;/p&gt;&lt;p&gt;--&lt;a href=&quot;/index.php/User:Dcrocha&quot; title=&quot;User:Dcrocha&quot;&gt;dcrocha&lt;/a&gt; 23:23, 24 November 2009 (UTC)
&lt;/p&gt;</description>
			<pubDate>Wed, 25 Nov 2009 18:52:29 GMT</pubDate>			<dc:creator>Dcrocha</dc:creator>			<comments>http://wiki.forum.nokia.com/index.php/Talk:Installing_Java_apps_and_WRT_widgets_using_sis_files</comments>		</item>
		<item>
			<title>TSS001494 - SAX parser comparison in Symbian/S60 and Qt</title>
			<link>http://wiki.forum.nokia.com/index.php/TSS001494_-_SAX_parser_comparison_in_Symbian/S60_and_Qt</link>
			<description>&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;div align=&quot;right&quot;&gt;&lt;a href=&quot;/index.php/File:KBTS_Header.gif&quot; class=&quot;image&quot; title=&quot;image:KBTS_Header.gif&quot;&gt;&lt;img alt=&quot;image:KBTS_Header.gif&quot; src=&quot;http://www.forum.nokia.com/piazza/wiki/images/3/31/KBTS_Header.gif&quot; width=&quot;770&quot; height=&quot;76&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;/index.php/KnowledgeBase&quot; title=&quot;KnowledgeBase&quot;&gt; Knowledge Base Home &lt;/a&gt;&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;table style=&quot;background:#eceff2&quot; width=&quot;660px&quot; border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;

&lt;tr&gt;
&lt;td&gt;&lt;b&gt;ID&lt;/b&gt; &lt;/td&gt;&lt;td&gt;TSS001494
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Creation date&lt;/b&gt; &lt;/td&gt;&lt;td&gt; November 23, 2009
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Platform&lt;/b&gt; &lt;/td&gt;&lt;td&gt; S60 3rd Edition, FP1&lt;br /&gt;S60 3rd Edition, FP2&lt;br /&gt;S60 5th Edition
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Devices&lt;/b&gt; &lt;/td&gt;&lt;td&gt; All (S60)
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Category&lt;/b&gt; &lt;/td&gt;&lt;td&gt; Symbian C++, Qt
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Subcategory&lt;/b&gt; &lt;/td&gt;&lt;td&gt; XML
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;table style=&quot;background:#eceff2&quot; width=&quot;660px&quot; border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;

&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Keywords (APIs, classes, methods, functions)&lt;/b&gt;: QXmlReader
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;a name=&quot;Overview&quot; id=&quot;Overview&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Overview&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;This article provides a comparison of XML document handling using Simple API for XML (SAX) parsers between Symbian/S60 and Qt.
&lt;/p&gt;
&lt;a name=&quot;Description&quot; id=&quot;Description&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt; Description &lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;SAX is an event-based standard interface for XML parsers. Details on SAX2 can be found at &lt;a href=&quot;http://www.saxproject.org&quot; class=&quot;external free&quot; title=&quot;http://www.saxproject.org&quot; rel=&quot;nofollow&quot;&gt;http://www.saxproject.org&lt;/a&gt;.
&lt;/p&gt;
&lt;a name=&quot;Comparison_of_SAX_.28SAX_2.0.29_parsing_in_Symbian.2FS60_and_Qt&quot; id=&quot;Comparison_of_SAX_.28SAX_2.0.29_parsing_in_Symbian.2FS60_and_Qt&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Comparison of SAX (SAX 2.0) parsing in Symbian/S60 and Qt&lt;/span&gt;&lt;/h2&gt;
&lt;table cellspacing=&quot;0&quot; border=&quot;1&quot;&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Operation&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Symbian/S60&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Qt&lt;/b&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Main Class/Interface&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;MContentHandler&lt;/tt&gt; interface. Also some classes extending the Symbian XML framework are provided by S60, mainly &lt;tt&gt;CSenXmlReader&lt;/tt&gt; and &lt;tt&gt;MSenContentHandlerClient&lt;/tt&gt;.
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;QXmlReader&lt;/tt&gt; interface (abstract class). Derived class &lt;tt&gt;QXmlSimpleReader&lt;/tt&gt; provides an implementation of a simple XML parser.
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Event reporting&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;MContentHandler&lt;/tt&gt; interface.&lt;br /&gt;
&lt;p&gt;For extensions; through the &lt;tt&gt;MSenContentHandlerClient&lt;/tt&gt; interface (not discussed here).
&lt;/p&gt;
&lt;/td&gt;&lt;td&gt;The reader reports parsing events through special handler classes:
&lt;p&gt;&lt;tt&gt;QxmlContentHandler&lt;/tt&gt;, &lt;tt&gt;QXmlDTDHandler&lt;/tt&gt;, &lt;tt&gt;QXmlErrorHandler&lt;/tt&gt;,&lt;br /&gt;&lt;tt&gt;QXmlEntityResolver&lt;/tt&gt;, &lt;tt&gt;QXmlDeclHandler&lt;/tt&gt;, &lt;tt&gt;QXmlLexicalHandler&lt;/tt&gt;.&lt;br /&gt;
The &lt;tt&gt;QXmlDefaultHandler&lt;/tt&gt; class provides a default implementation of all the XML handler classes.
This class gathers together the features of the above specialised handler classes.
&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Handling start of document&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;MContentHandler::OnStartDocumentL()&lt;/tt&gt;
&lt;/td&gt;&lt;td&gt;XML reader calls &lt;tt&gt;QXmlContentHandler::startDocument()&lt;/tt&gt;. Content handler can be set using &lt;tt&gt;QXmlReader::setContentHandler(QXmlContentHandler * handler)&lt;/tt&gt;.
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Handling end of document&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;MContentHandler::OnEndDocumentL()&lt;/tt&gt;
&lt;/td&gt;&lt;td&gt;XML reader calls &lt;tt&gt;QXmlContentHandler::endDocument()&lt;/tt&gt; after it has finished parsing.
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Handling start of element&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;MContentHandler::OnStartElementL()&lt;/tt&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;QXmlContentHandler::startElement()&lt;/tt&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Handling end of element&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;MContentHandler::OnEndElementL()&lt;/tt&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;QXmlContentHandler::endElement()&lt;/tt&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Handling tag contents&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;MContentHandler::OnContentL()&lt;/tt&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;QXmlContentHandler::characters()&lt;/tt&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Prefix-URI namespace mapping&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;MContentHandler::OnStartPrefixMappingL()&lt;/tt&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;QXmlContentHandler::startPrefixMapping()&lt;/tt&gt; and&lt;br /&gt;&lt;tt&gt;QXmlContentHandler::endPrefixMapping()&lt;/tt&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Error handling&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;MContentHandler::OnError()&lt;/tt&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;QXmlErrorHandler&lt;/tt&gt; class provides an interface to report errors in XML data.
&lt;p&gt;The error handler can be set with &lt;tt&gt;QXmlReader::setErrorHandler()&lt;/tt&gt;.
Errors can be reported using &lt;tt&gt;warning()&lt;/tt&gt;, &lt;tt&gt;error()&lt;/tt&gt;, and &lt;tt&gt;fatalError()&lt;/tt&gt;, with the error text being reported with &lt;tt&gt;errorString()&lt;/tt&gt;.
&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Resolving external entities&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;MContentHandler::OnSkippedEntityL()&lt;/tt&gt;
&lt;/td&gt;&lt;td&gt;The &lt;tt&gt;QXmlEntityResolver&lt;/tt&gt; class provides an interface to resolve external entities contained in XML data. Registering custom handlers for external entities is done with &lt;tt&gt;QXmlReader::setEntityResolver()&lt;/tt&gt;.
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;a name=&quot;Sample_Qt_code_for_SAX_parser&quot; id=&quot;Sample_Qt_code_for_SAX_parser&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Sample Qt code for SAX parser&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;The following code creates a &lt;tt&gt;QTreeView&lt;/tt&gt; from an XML document showing all XML tags and contents.
&lt;/p&gt;
&lt;pre class=&quot;cpp&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;class&lt;/span&gt; SAXHandler&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt; QXmlDefaultHandler&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;      &lt;br /&gt;  &lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;// Constructor and destructor&lt;/span&gt;&lt;br /&gt;    SAXHandler&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; QTreeView&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; tree &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; 0 &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;virtual&lt;/span&gt; ~SAXHandler&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;  &lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;   &lt;span style=&quot;color: #666666;&quot;&gt;// From QXmlDefaultHandler&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;bool&lt;/span&gt; startElement&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QString&lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt; namespaceURI, &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QString&lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt; localName, &lt;br /&gt;                       &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QString&lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt; qName, &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QXmlAttributes&lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt; atts &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;bool&lt;/span&gt; endElement&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QString&lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt; namespaceURI, &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QString&lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt; localName, &lt;br /&gt;                     &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QString&lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt; qName &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;bool&lt;/span&gt; characters&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QString&lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt; ch &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;bool&lt;/span&gt; endDocument&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;bool&lt;/span&gt; fatalError&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QXmlParseException&lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt; exception &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;  &lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;    QStandardItemModel&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt;   m_model&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;         &lt;span style=&quot;color: #666666;&quot;&gt;// Model of the tree to be filled&lt;/span&gt;&lt;br /&gt;    QStandardItem&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt;        m_currentItem&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;   &lt;span style=&quot;color: #666666;&quot;&gt;// Tag currently being parsed&lt;/span&gt;&lt;br /&gt;    QString               m_currentText&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;   &lt;span style=&quot;color: #666666;&quot;&gt;// Current text of the tag&lt;/span&gt;&lt;br /&gt;    QTreeView&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt;            m_tree&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;          &lt;span style=&quot;color: #666666;&quot;&gt;// Tree view to be filled&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;  SAXHandler&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;SAXHandler&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; QTreeView&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; tree &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    m_tree &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; atree&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    m_model &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; QStandardItemModel&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;  &lt;span style=&quot;color: #0000ff;&quot;&gt;bool&lt;/span&gt; SAXHandler&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;startElement&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QString &lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;/* namespaceURI */&lt;/span&gt;,&lt;br /&gt;                                 &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QString &lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;/* localName */&lt;/span&gt;,&lt;br /&gt;                                 &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QString &lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt;qName,&lt;br /&gt;                                 &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QXmlAttributes &lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt;attributes &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// Create a standard item with the qualified name and append it to model&lt;/span&gt;&lt;br /&gt;    m_currentItem &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt;  &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; QStandardItem&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; qName &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    m_model&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;appendRow&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; m_currentItem &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// List all the attributes&lt;/span&gt;&lt;br /&gt;    QStringList attrList&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; i &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt; attributes.&lt;span style=&quot;color: #007788;&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #000040;&quot;&gt;++&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;      attrList.&lt;span style=&quot;color: #007788;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; attributes.&lt;span style=&quot;color: #007788;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; i &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;  &lt;span style=&quot;color: #0000ff;&quot;&gt;bool&lt;/span&gt; SAXHandler&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;endElement&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QString &lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;/* namespaceURI */&lt;/span&gt;,&lt;br /&gt;                               &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QString &lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;/* localName */&lt;/span&gt;,&lt;br /&gt;                               &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QString &lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt;qName &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// Appending the row with text from current tag&lt;/span&gt;&lt;br /&gt;    m_currentItem&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;appendRow&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; QStandardItem&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; m_currentText &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    m_currentText.&lt;span style=&quot;color: #007788;&quot;&gt;clear&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;  &lt;span style=&quot;color: #0000ff;&quot;&gt;bool&lt;/span&gt; SAXHandler&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;characters&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QString &lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt;str &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    m_currentText.&lt;span style=&quot;color: #007788;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; str &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;  &lt;span style=&quot;color: #0000ff;&quot;&gt;bool&lt;/span&gt; SAXHandler&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;endDocument&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// Model is now fully constructed with tags and content&lt;/span&gt;&lt;br /&gt;    m_tree&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;setModel&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; m_model &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;  &lt;span style=&quot;color: #666666;&quot;&gt;// XML reader uses this function to report a non-recoverable error &lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color: #666666;&quot;&gt;// Details of the error are stored in QXmlParseException&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color: #0000ff;&quot;&gt;bool&lt;/span&gt; SAXHandler&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;fatalError&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; QXmlParseException &lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt;exception &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// column number and line where the error ocurred&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; col &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; exception.&lt;span style=&quot;color: #007788;&quot;&gt;columnNumber&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; line &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; exception.&lt;span style=&quot;color: #007788;&quot;&gt;lineNumber&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// error message&lt;/span&gt;&lt;br /&gt;    QString msg &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; exception.&lt;span style=&quot;color: #007788;&quot;&gt;message&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;  SAXHandler&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;~SAXHandler&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;&lt;b&gt;Setting an input source, content and error handlers for the XML reader&lt;/b&gt;
&lt;/p&gt;
&lt;pre class=&quot;cpp&quot; style=&quot;font-family:monospace;&quot;&gt;QFile file&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; myXMLFile &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000040;&quot;&gt;!&lt;/span&gt;file.&lt;span style=&quot;color: #007788;&quot;&gt;open&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; QIODevice&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;ReadOnly&lt;/span&gt; &lt;span style=&quot;color: #000040;&quot;&gt;|&lt;/span&gt; QIODevice&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;Text&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// Handle file opening error&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;  QXmlInputSource&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; xmlInput &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; QXmlInputSource&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt;file &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;  &lt;span style=&quot;color: #666666;&quot;&gt;// Contruct a custom QXmlDefaultHandler-derived handler&lt;/span&gt;&lt;br /&gt;  SAXHandler&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; handler &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; SAXHandler&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; m_tree &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;  &lt;span style=&quot;color: #666666;&quot;&gt;// Use our own class as both content and error handler&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color: #666666;&quot;&gt;// m_reader is of type QXmlSimpleReader &lt;/span&gt;&lt;br /&gt;  m_reader.&lt;span style=&quot;color: #007788;&quot;&gt;setContentHandler&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; handler &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  m_reader.&lt;span style=&quot;color: #007788;&quot;&gt;setErrorHandler&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; handler &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;  m_reader.&lt;span style=&quot;color: #007788;&quot;&gt;parse&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; xmlInput &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
</description>
			<pubDate>Mon, 23 Nov 2009 13:34:44 GMT</pubDate>			<dc:creator>Forum Nokia KB</dc:creator>			<comments>http://wiki.forum.nokia.com/index.php/Talk:TSS001494_-_SAX_parser_comparison_in_Symbian/S60_and_Qt</comments>		</item>
		<item>
			<title>TSS001493 - DOM parser comparison in Symbian/S60 and Qt</title>
			<link>http://wiki.forum.nokia.com/index.php/TSS001493_-_DOM_parser_comparison_in_Symbian/S60_and_Qt</link>
			<description>&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;div align=&quot;right&quot;&gt;&lt;a href=&quot;/index.php/File:KBTS_Header.gif&quot; class=&quot;image&quot; title=&quot;image:KBTS_Header.gif&quot;&gt;&lt;img alt=&quot;image:KBTS_Header.gif&quot; src=&quot;http://www.forum.nokia.com/piazza/wiki/images/3/31/KBTS_Header.gif&quot; width=&quot;770&quot; height=&quot;76&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;/index.php/KnowledgeBase&quot; title=&quot;KnowledgeBase&quot;&gt; Knowledge Base Home &lt;/a&gt;&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;table style=&quot;background:#eceff2&quot; width=&quot;660px&quot; border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;

&lt;tr&gt;
&lt;td&gt;&lt;b&gt;ID&lt;/b&gt; &lt;/td&gt;&lt;td&gt;TSS001493
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Creation date&lt;/b&gt; &lt;/td&gt;&lt;td&gt; November 23, 2009
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Platform&lt;/b&gt; &lt;/td&gt;&lt;td&gt; S60 3rd Edition FP2, S60 5th Edition
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Devices&lt;/b&gt; &lt;/td&gt;&lt;td&gt; Nokia N96, Nokia 5800 XpressMusic
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Category&lt;/b&gt; &lt;/td&gt;&lt;td&gt; Qt
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Subcategory&lt;/b&gt; &lt;/td&gt;&lt;td&gt; XML
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;table style=&quot;background:#eceff2&quot; width=&quot;660px&quot; border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;

&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Keywords (APIs, classes, methods, functions)&lt;/b&gt;: XML, DOM Parser
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;a name=&quot;Overview&quot; id=&quot;Overview&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Overview&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;This article provides a comparison of Document Object Model (DOM) parser in Symbian/S60 and Qt.
&lt;/p&gt;
&lt;a name=&quot;Description&quot; id=&quot;Description&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt; Description &lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;DOM provides an interface to access and change the content and structure of an XML file. It makes a hierarchical (tree) view of the document. Thus, in contrast to the SAX2 interface, an object model of the document is resident in memory after parsing which makes manipulation easy. For more information, visit &lt;a href=&quot;http://www.w3.org/DOM/&quot; class=&quot;external free&quot; title=&quot;http://www.w3.org/DOM/&quot; rel=&quot;nofollow&quot;&gt;http://www.w3.org/DOM/&lt;/a&gt;
&lt;/p&gt;
&lt;a name=&quot;Comparison_of_DOM_parsing_in_Symbian.2FS60_and_Qt&quot; id=&quot;Comparison_of_DOM_parsing_in_Symbian.2FS60_and_Qt&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Comparison of DOM parsing in Symbian/S60 and Qt&lt;/span&gt;&lt;/h2&gt;
&lt;table cellspacing=&quot;0&quot; border=&quot;1&quot;&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Operation&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Symbian/S60 5th Edition&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Qt on Symbian&lt;/b&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Library/Module&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;XmlEngineDom.lib
&lt;/td&gt;&lt;td&gt;QtXml Module
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;DOM Document&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;RXmlEngDocument&lt;/tt&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;QDomDocument&lt;/tt&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Creating (parsing)a DOM tree&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;RXmlEngDOMParser::ParseFileL()&lt;/tt&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;QDomDocument::setContent()&lt;/tt&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Extracting root (document) element&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;RXmlEngDocument::DocumentElement()&lt;/tt&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;QDomDocument::documentElement()&lt;/tt&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;DOM elements&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;TXmlEngElement&lt;/tt&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;QDomElement&lt;/tt&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Traversing nodes&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;TXmlEngNode::FirstChild()&lt;/tt&gt; to get the first child (if any), &lt;tt&gt;TXmlEngNode::NextSibling()&lt;/tt&gt; to traverse.
&lt;p&gt;Also see &lt;tt&gt;LastChild(), &amp;lt;tt&amp;gt;PreviousSibling()&lt;/tt&gt; and &lt;tt&gt;ParentNode()&lt;/tt&gt;. To find a node with a particular name, use &lt;tt&gt;Name()&lt;/tt&gt;.
&lt;/p&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;QDomNode::firstChild()&lt;/tt&gt; to get the first child (if any), and &lt;tt&gt;QDomNode::nextSibling()&lt;/tt&gt; to traverse. Also see &lt;tt&gt;lastChild()&lt;/tt&gt;, &lt;tt&gt;previousSibling()&lt;/tt&gt; and &lt;tt&gt;parentNode()&lt;/tt&gt;. To find a node with a particular name, use &lt;tt&gt;namedItem()&lt;/tt&gt;.
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Extracting tag name&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;When &lt;tt&gt;TXmlEngNode::NodeType()&lt;/tt&gt; is &lt;tt&gt;EElement&lt;/tt&gt;,  &lt;tt&gt;TXmlEngNode::Name()&lt;/tt&gt; returns the tag name.
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;QDomElement::tagName()&lt;/tt&gt; returns the tag name for an element.
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Extracting attributes&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;Instance of the &lt;tt&gt;TXmlEngAttr&lt;/tt&gt; class represents an XML attribute. &lt;tt&gt;TXmlEngAttr::Value()&lt;/tt&gt; returns the attribute value.
&lt;p&gt;&lt;tt&gt;TXmlEngElement::AttributeValueL()&lt;/tt&gt; returns a value of an attribute with given name and namespace URI.
&lt;/p&gt;
&lt;/td&gt;&lt;td&gt;Element attributes are represented by &lt;tt&gt;QDomAttr&lt;/tt&gt; objects, queried using &lt;tt&gt;QDomElement::attribute()&lt;/tt&gt; and &lt;tt&gt;QDomElement::attributeNode()&lt;/tt&gt;.
&lt;p&gt;&lt;tt&gt;QDomAttr::value()&lt;/tt&gt; returns the attribute value. &lt;tt&gt;QDomAttr::name()&lt;/tt&gt; returns the attribute name.
&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Extracting text of the element&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;TXmlEngElement::Text()&lt;/tt&gt; returns the content of the element.
&lt;p&gt;&lt;tt&gt;TXmlEngTextNode&lt;/tt&gt; interface inherits from &lt;tt&gt;TXmlEngCharacterData&lt;/tt&gt; and represents the textual content (&quot;character data&quot; in XML) of an element or attribute. &lt;tt&gt;TXmlEngCharacterData::Contents()&lt;/tt&gt; returns the content of the node.
&lt;/p&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;QDomElement::text()&lt;/tt&gt; returns text for the element.
&lt;p&gt;To find all text in all of node's children, iterate over the children looking for &lt;tt&gt;QDomText&lt;/tt&gt; nodes and get the text using &lt;tt&gt;QDomText::data()&lt;/tt&gt;.
&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;XML comments&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;TXmlEngComment&lt;/tt&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;QDomComment&lt;/tt&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;XML processing instructions&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;TXmlEngProcessingInstruction&lt;/tt&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;QDomProcessingInstruction&lt;/tt&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;CDATA sections&lt;/b&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;TXmlEngCDATASection&lt;/tt&gt;
&lt;/td&gt;&lt;td&gt;&lt;tt&gt;QDomCDATASection&lt;/tt&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;br /&gt;
&lt;a name=&quot;Sample_Qt_code_for_DOM_parser&quot; id=&quot;Sample_Qt_code_for_DOM_parser&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Sample Qt code for DOM parser&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;The following code snippet creates a tree view from an XML document with all the tags, content, and attributes.
&lt;/p&gt;
&lt;pre class=&quot;cpp&quot; style=&quot;font-family:monospace;&quot;&gt;QDOMSimple&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;QDOMSimple&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; QWidget &lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt;parent &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;  &lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt; QWidget&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; parent &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// DOM document&lt;/span&gt;&lt;br /&gt;    QDomDocument doc&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;title&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// Opening the XML file to be parsed&lt;/span&gt;&lt;br /&gt;    QFile file&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; XMLFILENAME &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; file.&lt;span style=&quot;color: #007788;&quot;&gt;open&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; QIODevice&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;ReadOnly&lt;/span&gt; &lt;span style=&quot;color: #000040;&quot;&gt;|&lt;/span&gt; QIODevice&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;Text&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #666666;&quot;&gt;// The tree view to be filled with xml data &lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #666666;&quot;&gt;// (m_tree is a class member variable)&lt;/span&gt;&lt;br /&gt;      m_tree &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; QTreeWidget&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;this&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #666666;&quot;&gt;// Creating the DOM tree&lt;/span&gt;&lt;br /&gt;      doc.&lt;span style=&quot;color: #007788;&quot;&gt;setContent&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt;file &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      file.&lt;span style=&quot;color: #007788;&quot;&gt;close&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #666666;&quot;&gt;// Root of the document&lt;/span&gt;&lt;br /&gt;      QDomElement root &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; doc.&lt;span style=&quot;color: #007788;&quot;&gt;documentElement&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #666666;&quot;&gt;// Taking the first child node of the root&lt;/span&gt;&lt;br /&gt;      QDomNode child &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; root.&lt;span style=&quot;color: #007788;&quot;&gt;firstChild&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #666666;&quot;&gt;// Setting the root as the header of the tree&lt;/span&gt;&lt;br /&gt;      QTreeWidgetItem&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; header &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; QTreeWidgetItem&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      header&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;setText&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; 0, root.&lt;span style=&quot;color: #007788;&quot;&gt;nodeName&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      m_tree&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;setHeaderItem&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; header &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #666666;&quot;&gt;// Parse until the end of document&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #0000ff;&quot;&gt;while&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000040;&quot;&gt;!&lt;/span&gt;child.&lt;span style=&quot;color: #007788;&quot;&gt;isNull&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #666666;&quot;&gt;//Convert a DOM node to DOM element&lt;/span&gt;&lt;br /&gt;        QDomElement element &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; child.&lt;span style=&quot;color: #007788;&quot;&gt;toElement&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #666666;&quot;&gt;//Parse only if the node is a really an element&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000040;&quot;&gt;!&lt;/span&gt;element.&lt;span style=&quot;color: #007788;&quot;&gt;isNull&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;          &lt;span style=&quot;color: #666666;&quot;&gt;//Parse the element recursively&lt;/span&gt;&lt;br /&gt;          parseElement&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; element &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;          &lt;span style=&quot;color: #666666;&quot;&gt;//Go to the next sibling&lt;/span&gt;&lt;br /&gt;          child &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; child.&lt;span style=&quot;color: #007788;&quot;&gt;nextSiblingElement&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;          &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;      m_tree&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;setGeometry&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; QApplication&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;desktop&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;availableGeometry&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      setGeometry&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; QApplication&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;desktop&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;availableGeometry&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;  &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; QDOMSimple&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;parseElement&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; QDomElement&lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt; aElement, QTreeWidgetItem&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; aParentItem &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// A map of all attributes of an element&lt;/span&gt;&lt;br /&gt;    QDomNamedNodeMap attrMap &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; aElement.&lt;span style=&quot;color: #007788;&quot;&gt;attributes&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// List all attributes&lt;/span&gt;&lt;br /&gt;    QStringList attrList&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; i &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt; attrMap.&lt;span style=&quot;color: #007788;&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #000040;&quot;&gt;++&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #666666;&quot;&gt;// Attribute name&lt;/span&gt;&lt;br /&gt;      QString attr &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; attrMap.&lt;span style=&quot;color: #007788;&quot;&gt;item&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; i &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #007788;&quot;&gt;nodeName&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      attr.&lt;span style=&quot;color: #007788;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;-&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #666666;&quot;&gt;// Attribute value&lt;/span&gt;&lt;br /&gt;      attr.&lt;span style=&quot;color: #007788;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; attrMap.&lt;span style=&quot;color: #007788;&quot;&gt;item&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; i &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #007788;&quot;&gt;nodeValue&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      attrList.&lt;span style=&quot;color: #007788;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; attr &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;    QTreeWidgetItem&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; item&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// Create a new view item for elements having child nodes&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; aParentItem &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;      item &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; QTreeWidgetItem&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; aParentItem &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// Create a new view item for elements without child nodes&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;      item &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; QTreeWidgetItem&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; m_tree &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;//Set tag name and the text&lt;/span&gt;&lt;br /&gt;    QString tagNText&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    tagNText.&lt;span style=&quot;color: #007788;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; aElement.&lt;span style=&quot;color: #007788;&quot;&gt;tagName&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    tagNText.&lt;span style=&quot;color: #007788;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;-&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    tagNText.&lt;span style=&quot;color: #007788;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; aElement.&lt;span style=&quot;color: #007788;&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    item&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;setText&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; 0, tagNText &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// Append attributes to the element node of the tree&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; i &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt; attrList.&lt;span style=&quot;color: #007788;&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #000040;&quot;&gt;++&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;      QTreeWidgetItem&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; attrItem &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; QTreeWidgetItem&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; item &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      attrItem&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;setText&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; 0, attrList&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// Repeat the process recursively for child elements&lt;/span&gt;&lt;br /&gt;    QDomElement child &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; aElement.&lt;span style=&quot;color: #007788;&quot;&gt;firstChildElement&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #0000ff;&quot;&gt;while&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000040;&quot;&gt;!&lt;/span&gt;child.&lt;span style=&quot;color: #007788;&quot;&gt;isNull&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;      parseElement&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; child, item &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      child &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; child.&lt;span style=&quot;color: #007788;&quot;&gt;nextSiblingElement&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
</description>
			<pubDate>Mon, 23 Nov 2009 13:01:14 GMT</pubDate>			<dc:creator>Forum Nokia KB</dc:creator>			<comments>http://wiki.forum.nokia.com/index.php/Talk:TSS001493_-_DOM_parser_comparison_in_Symbian/S60_and_Qt</comments>		</item>
		<item>
			<title>KIS001492 - Accessing the menu bar of dialog-based applications returns a null pointer</title>
			<link>http://wiki.forum.nokia.com/index.php/KIS001492_-_Accessing_the_menu_bar_of_dialog-based_applications_returns_a_null_pointer</link>
			<description>&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;div align=&quot;right&quot;&gt;&lt;a href=&quot;/index.php/File:KBKI_Header.gif&quot; class=&quot;image&quot; title=&quot;image:KBKI_Header.gif&quot;&gt;&lt;img alt=&quot;image:KBKI_Header.gif&quot; src=&quot;http://www.forum.nokia.com/piazza/wiki/images/4/46/KBKI_Header.gif&quot; width=&quot;708&quot; height=&quot;71&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;/index.php/KnowledgeBase&quot; title=&quot;KnowledgeBase&quot;&gt; Knowledge Base Home &lt;/a&gt;&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;table style=&quot;background:#eceff2&quot; width=&quot;660px&quot; border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;

&lt;tr&gt;
&lt;td&gt;&lt;b&gt;ID&lt;/b&gt; &lt;/td&gt;&lt;td&gt;KIS001492
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Creation date&lt;/b&gt; &lt;/td&gt;&lt;td&gt; November 23, 2009
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Platform&lt;/b&gt; &lt;/td&gt;&lt;td&gt; S60 3rd Edition (All Feature Packs)&lt;br /&gt;S60 5th Edition
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Devices&lt;/b&gt; &lt;/td&gt;&lt;td&gt; All (S60)
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Category&lt;/b&gt; &lt;/td&gt;&lt;td&gt; Symbian C++
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Subcategory&lt;/b&gt; &lt;/td&gt;&lt;td&gt; UI
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;table style=&quot;background:#eceff2&quot; width=&quot;660px&quot; border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;

&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Keywords (APIs, classes, methods, functions)&lt;/b&gt;: MenuBar()
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;a name=&quot;Overview&quot; id=&quot;Overview&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Overview&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;Accessing the menu bar of dialog-based applications, for example to modify menu contents at runtime, returns a null pointer if no menu bar is defined in resources.
&lt;/p&gt;&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;a name=&quot;Description&quot; id=&quot;Description&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Description&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;tt&gt;CEikonEnv::Static()-&amp;gt;AppUiFactory()-&amp;gt;MenuBar()&lt;/tt&gt; can be used in an S60 UI application to access the menu bar (a pointer to the &lt;tt&gt;CEikMenuBar&lt;/tt&gt; instance), defined in the &lt;tt&gt;EIK_APP_INFO&lt;/tt&gt; resource as follows:
&lt;/p&gt;
&lt;pre class=&quot;text&quot; style=&quot;font-family:monospace;&quot;&gt;RESOURCE EIK_APP_INFO&lt;br /&gt;   {&lt;br /&gt;   menubar = r_myapp_menu_bar;          /* a link to a MENU_BAR resource */&lt;br /&gt;   cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;&lt;br /&gt;   }&lt;/pre&gt;
&lt;p&gt;A dialog-based application that omits the &lt;tt&gt;menubar&lt;/tt&gt; definition will receive a null pointer when trying to access the menu bar using the above function.
&lt;/p&gt;&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;a name=&quot;Solution&quot; id=&quot;Solution&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Solution&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;Define a menu bar in the &lt;tt&gt;EIK_APP_INFO&lt;/tt&gt; resource for a dialog-based application, then use the following &lt;tt&gt;buttons&lt;/tt&gt; definition in the &lt;tt&gt;DIALOG&lt;/tt&gt; resource:
&lt;/p&gt;
&lt;pre class=&quot;text&quot; style=&quot;font-family:monospace;&quot;&gt;RESOURCE DIALOG r_myapp_main_dialog&lt;br /&gt;   {  &lt;br /&gt;   buttons = R_AVKON_SOFTKEYS_OPTIONS_EXIT;&lt;br /&gt;   ...&lt;br /&gt;   }&lt;/pre&gt;
&lt;p&gt;As a result, the menu bar (&lt;b&gt;Options&lt;/b&gt; menu) can be accessed with &lt;tt&gt;CEikonEnv::Static()-&amp;gt;AppUiFactory()-&amp;gt;MenuBar()&lt;/tt&gt;. 
&lt;/p&gt;&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;a name=&quot;See_also&quot; id=&quot;See_also&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;See also&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;See &lt;a href=&quot;http://www.forum.nokia.com/info/sw.nokia.com/id/46d7f03e-2275-40c7-b72c-3d2c74e105e6/S60_Platform_Time_Zone_Localiser_Example.html&quot; class=&quot;external text&quot; title=&quot;http://www.forum.nokia.com/info/sw.nokia.com/id/46d7f03e-2275-40c7-b72c-3d2c74e105e6/S60_Platform_Time_Zone_Localiser_Example.html&quot; rel=&quot;nofollow&quot;&gt;S60 Platform: Time Zone Localiser Example&lt;/a&gt; for an example of a dialog-based application.
&lt;/p&gt;</description>
			<pubDate>Mon, 23 Nov 2009 10:14:55 GMT</pubDate>			<dc:creator>Forum Nokia KB</dc:creator>			<comments>http://wiki.forum.nokia.com/index.php/Talk:KIS001492_-_Accessing_the_menu_bar_of_dialog-based_applications_returns_a_null_pointer</comments>		</item>
		<item>
			<title>Adding a Guarana UI button on a web page</title>
			<link>http://wiki.forum.nokia.com/index.php/Adding_a_Guarana_UI_button_on_a_web_page</link>
			<description>&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;table style=&quot;background:#eceff2&quot; width=&quot;660px&quot; border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;

&lt;tr&gt;
&lt;td&gt;&lt;b&gt;ID&lt;/b&gt; &lt;/td&gt;&lt;td&gt;&amp;nbsp;
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Creation date&lt;/b&gt; &lt;/td&gt;&lt;td&gt; November 23, 2009
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Platform&lt;/b&gt; &lt;/td&gt;&lt;td&gt;
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Tested on devices&lt;/b&gt; &lt;/td&gt;&lt;td&gt; Nokia N97
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Category&lt;/b&gt; &lt;/td&gt;&lt;td&gt; Web Runtime (WRT)
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Subcategory&lt;/b&gt; &lt;/td&gt;&lt;td&gt; Guarana UI, UI
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;table style=&quot;background:#eceff2&quot; width=&quot;660px&quot; border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;

&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Keywords (APIs, classes, methods, functions)&lt;/b&gt;:
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;a name=&quot;Overview&quot; id=&quot;Overview&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Overview&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;This code snippet demonstrates how to add a button on a web page using Guarana UI components. The button component looks like this:&lt;br /&gt;
&lt;a href=&quot;/index.php/File:Guarana_button_icon.jpg&quot; class=&quot;image&quot; title=&quot;File:Guarana_button_icon.jpg&quot;&gt;&lt;img alt=&quot;File:Guarana_button_icon.jpg&quot; src=&quot;http://www.forum.nokia.com/piazza/wiki/images/1/13/Guarana_button_icon.jpg&quot; width=&quot;100&quot; height=&quot;100&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
You can download the component library from &lt;a href=&quot;http://wiki.forum.nokia.com/index.php/Guarana_UI:_a_jQuery-Based_UI_Library_for_Nokia_WRT&quot; class=&quot;external text&quot; title=&quot;http://wiki.forum.nokia.com/index.php/Guarana_UI:_a_jQuery-Based_UI_Library_for_Nokia_WRT&quot; rel=&quot;nofollow&quot;&gt;Forum Nokia&lt;/a&gt;. The button component requires the following files from the library:
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt; lib/jquery/jquery.js
&lt;/li&gt;&lt;li&gt; src/core.js
&lt;/li&gt;&lt;li&gt; src/defaults.js
&lt;/li&gt;&lt;li&gt; src/dom.js
&lt;/li&gt;&lt;li&gt; src/util.js
&lt;/li&gt;&lt;li&gt; src/widget.js
&lt;/li&gt;&lt;li&gt; src/button.js
&lt;/li&gt;&lt;li&gt; themes/nokia/base/base.css
&lt;/li&gt;&lt;li&gt; themes/nokia/base/button.css
&lt;/li&gt;&lt;li&gt; themes/nokia/base/custom.css
&lt;/li&gt;&lt;li&gt; themes/nokia/base/images/shadow.png (from base.css)
&lt;/li&gt;&lt;li&gt; themes/nokia/base/images/shadow-c.png (from base.css)
&lt;/li&gt;&lt;li&gt; themes/nokia/base/images/shadow-lr.png (from base.css)
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/ui.accordion.css
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/ui.all.css
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/ui.base.css
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/ui.core.css
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/ui.theme.css
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/images/ui-bg_diagonals-thick_10_444444_40x40.png (from ui.theme.css)
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/images/ui-bg_flat_0_000000_40x100.png (from ui.theme.css)
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/images/ui-bg_glass_20_9f1504_640x400.png (from ui.theme.css)
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/images/ui-bg_glass_40_8ab61c_640x400.png (from ui.theme.css)
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/images/ui-bg_glass_55_8ab61c_640x400.png (from ui.theme.css)
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/images/ui-bg_highlight-hard_80_ededed_640x100.png (from ui.theme.css)
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/images/ui-bg_highlight-soft_100_ededed_640x100.png (from ui.theme.css)
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/images/ui-icons_89bf43_256x240.png (from ui.theme.css)
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/images/ui-icons_97B72B_256x240.png (from ui.theme.css)
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/images/ui-icons_222222_256x240.png (from ui.theme.css)
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/images/ui-icons_e3bfb5_256x240.png (from ui.theme.css)
&lt;/li&gt;&lt;li&gt; themes/themeroller/default-theme/images/ui-icons_ffffff_256x240.png (from ui.theme.css)
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Source:_Relevant_HTML_components&quot; id=&quot;Source:_Relevant_HTML_components&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Source: Relevant HTML components&lt;/span&gt;&lt;/h2&gt;
&lt;pre class=&quot;xml&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;head&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Guarana UI style sheets --&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;link&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;style/themes/nokia/base/base.css&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;        &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;media&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;screen&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;link&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;style/themes/nokia/base/button.css&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;        &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;media&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;screen&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;link&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;rel&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;        &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;style/themes/themeroller/default-theme/ui.all.css&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;        &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;media&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;screen&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- Guarana UI scripts --&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;lib/jquery/jquery.js&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;        &lt;span style=&quot;color: #000066;&quot;&gt;charset&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;lib/guarana/core.js&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;        &lt;span style=&quot;color: #000066;&quot;&gt;charset&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;lib/guarana/defaults.js&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;        &lt;span style=&quot;color: #000066;&quot;&gt;charset&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;lib/guarana/dom.js&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;        &lt;span style=&quot;color: #000066;&quot;&gt;charset&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;lib/guarana/util.js&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;        &lt;span style=&quot;color: #000066;&quot;&gt;charset&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;lib/guarana/widget.js&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;        &lt;span style=&quot;color: #000066;&quot;&gt;charset&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;lib/guarana/button.js&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;        &lt;span style=&quot;color: #000066;&quot;&gt;charset&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/script&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/head&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;body&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;bodyContent&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;bodyContent&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- A regular push button --&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;span&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;btnPush&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/span&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;&amp;lt;!-- A toggle button --&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;span&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;btnToggle&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/span&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/div&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/body&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a name=&quot;Source:_JavaScript&quot; id=&quot;Source:_JavaScript&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Source: JavaScript&lt;/span&gt;&lt;/h2&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// Initializes the widget&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; init&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    window.&lt;span style=&quot;color: #660066;&quot;&gt;btnPush&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;new&lt;/span&gt; Nokia.&lt;span style=&quot;color: #660066;&quot;&gt;Button&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;        element&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;#btnPush&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        label&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;Push me!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        click&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt; printString&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;Thank You!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;    &lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;To disable the button, call the &lt;tt&gt;disable()&lt;/tt&gt; function:
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// Disable the push button&lt;/span&gt;&lt;br /&gt;window.&lt;span style=&quot;color: #660066;&quot;&gt;btnPush&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;disable&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;To create a toggle button, use the &lt;tt&gt;keeppressed&lt;/tt&gt; attribute:
&lt;/p&gt;
&lt;pre class=&quot;javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #006600; font-style: italic;&quot;&gt;// Initializes the widget&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; init&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    window.&lt;span style=&quot;color: #660066;&quot;&gt;btnToggle&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;new&lt;/span&gt; Nokia.&lt;span style=&quot;color: #660066;&quot;&gt;Button&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;        element&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;#btnToggle&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        keeppressed&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        label&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;Pressed&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        pressed&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        width&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; 90&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        press&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;            &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;setLabel&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;Pressed&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;        unpress&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;            &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #660066;&quot;&gt;setLabel&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&amp;quot;Unpressed&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;tt&gt;press()&lt;/tt&gt; and &lt;tt&gt;unpress()&lt;/tt&gt; functions above are called when the button is toggled and untoggled, respectively. The constant &lt;tt&gt;width&lt;/tt&gt; attribute ensures that the width of the button is not changed when its label is changed.
&lt;/p&gt;
&lt;a name=&quot;Postconditions&quot; id=&quot;Postconditions&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Postconditions&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;A Guarana UI button is added on the web page.
&lt;/p&gt;
&lt;a name=&quot;See_also&quot; id=&quot;See_also&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;See also&lt;/span&gt;&lt;/h2&gt;
&lt;ul&gt;&lt;li&gt; &lt;a href=&quot;/index.php?title=Customizing_a_Guarana_UI_button&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Customizing a Guarana UI button (page does not exist)&quot;&gt;Customizing a Guarana UI button&lt;/a&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;a name=&quot;Supplementary_material&quot; id=&quot;Supplementary_material&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt;Supplementary material&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;This code snippet is part of the stub concept, which means that it has been patched on top of a template application in order to be more useful for developers. The version of the WRT stub application used as a template in this snippet is v1.2.
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt; The patched, executable application that can be used to test the features described in this snippet is available for download at &lt;a href=&quot;http://www.forum.nokia.com/piazza/wiki/images/b/bd/Adding_a_guarana_ui_button.zip&quot; class=&quot;internal&quot; title=&quot;Adding a guarana ui button.zip&quot;&gt;Media:adding_a_guarana_ui_button.zip&lt;/a&gt;.
&lt;/li&gt;&lt;li&gt; You can view all the changes that are required to implement the above-mentioned features. The changes are provided in unified diff and colour-coded diff (HTML) formats in &lt;a href=&quot;http://www.forum.nokia.com/piazza/wiki/images/d/df/Adding_a_guarana_ui_button.diff.zip&quot; class=&quot;internal&quot; title=&quot;Adding a guarana ui button.diff.zip&quot;&gt;Media:adding_a_guarana_ui_button.diff.zip&lt;/a&gt;.
&lt;/li&gt;&lt;li&gt; For general information on applying the patch, see &lt;a href=&quot;/index.php/Using_Diffs&quot; title=&quot;Using Diffs&quot;&gt;Using Diffs&lt;/a&gt;.
&lt;/li&gt;&lt;li&gt; For unpatched stub applications, see &lt;a href=&quot;/index.php/Example_stub&quot; title=&quot;Example stub&quot;&gt;Example stub&lt;/a&gt;.
&lt;/li&gt;&lt;/ul&gt;
</description>
			<pubDate>Mon, 23 Nov 2009 14:16:07 GMT</pubDate>			<dc:creator>Tapla</dc:creator>			<comments>http://wiki.forum.nokia.com/index.php/Talk:Adding_a_Guarana_UI_button_on_a_web_page</comments>		</item>
		<item>
			<title>TSS001491 - Retrieving the list of applications using an active connection</title>
			<link>http://wiki.forum.nokia.com/index.php/TSS001491_-_Retrieving_the_list_of_applications_using_an_active_connection</link>
			<description>&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;div align=&quot;right&quot;&gt;&lt;a href=&quot;/index.php/File:KBTS_Header.gif&quot; class=&quot;image&quot; title=&quot;image:KBTS_Header.gif&quot;&gt;&lt;img alt=&quot;image:KBTS_Header.gif&quot; src=&quot;http://www.forum.nokia.com/piazza/wiki/images/3/31/KBTS_Header.gif&quot; width=&quot;770&quot; height=&quot;76&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;/index.php/KnowledgeBase&quot; title=&quot;KnowledgeBase&quot;&gt; Knowledge Base Home &lt;/a&gt;&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;table style=&quot;background:#eceff2&quot; width=&quot;660px&quot; border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;

&lt;tr&gt;
&lt;td&gt;&lt;b&gt;ID&lt;/b&gt; &lt;/td&gt;&lt;td&gt;TSS001491
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Creation date&lt;/b&gt; &lt;/td&gt;&lt;td&gt; November 23, 2009
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Platform&lt;/b&gt; &lt;/td&gt;&lt;td&gt; S60 3rd Edition&lt;br /&gt; S60 5th Edition
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Devices&lt;/b&gt; &lt;/td&gt;&lt;td&gt; S60 (All)
&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Category&lt;/b&gt; &lt;/td&gt;&lt;td&gt; Symbian C++
&lt;/td&gt;&lt;td&gt;&lt;b&gt;Subcategory&lt;/b&gt; &lt;/td&gt;&lt;td&gt; Networking
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;table style=&quot;background:#eceff2&quot; width=&quot;660px&quot; border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;

&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Keywords (APIs, classes, methods, functions)&lt;/b&gt;: RConnectionMonitor, KClientInfo
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;a name=&quot;Description&quot; id=&quot;Description&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt; Description &lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;tt&gt;RConnectionMonitor&lt;/tt&gt; class provides methods for resolving the UIDs of applications which are using a specific connection. The list of application UIDs is retrieved by passing a valid connection of an existing connection ID and a &lt;tt&gt;KClientInfo&lt;/tt&gt; attribute for the &lt;tt&gt;RConnectionMonitor::GetPckgAttribute()&lt;/tt&gt; method. The results are obtained through a package from which the UIDs can be read.
&lt;/p&gt;
&lt;a name=&quot;Solution&quot; id=&quot;Solution&quot;&gt;&lt;/a&gt;&lt;h2&gt; &lt;span class=&quot;mw-headline&quot;&gt; Solution &lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;b&gt;Required Headers &amp;amp; Libraries:&lt;/b&gt;
&lt;/p&gt;
&lt;pre class=&quot;text&quot; style=&quot;font-family:monospace;&quot;&gt;#include &amp;lt;rconnmon.h&amp;gt; // Link against connmon.lib&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Code:&lt;/b&gt;
&lt;/p&gt;
&lt;pre class=&quot;cpp&quot; style=&quot;font-family:monospace;&quot;&gt;RConnectionMonitor monitor&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt; TRequestStatus status1, status2&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt; TUint connectionCount&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; 0 &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt; TUint subConnectionCount&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; 0 &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt; TUint connectionId&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; 0 &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;br&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; monitor.&lt;span style=&quot;color: #007788;&quot;&gt;ConnectL&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;// Open RConnectionMonitor object&amp;lt;br&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style=&quot;color: #666666;&quot;&gt;// Get connection count&lt;/span&gt;&lt;br /&gt; monitor.&lt;span style=&quot;color: #007788;&quot;&gt;GetConnectionCount&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; connectionCount, status1 &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt; User&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;WaitForRequest&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; status1 &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;br&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; status1.&lt;span style=&quot;color: #007788;&quot;&gt;Int&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000040;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; KErrNone &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// Handle errors&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; connectionCount &lt;span style=&quot;color: #000080;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// No connection &lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt; &lt;span style=&quot;color: #666666;&quot;&gt;// Get connection info of the 1st connection&lt;/span&gt;&lt;br /&gt; TInt error &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; monitor.&lt;span style=&quot;color: #007788;&quot;&gt;GetConnectionInfo&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; 1, connectionId, subConnectionCount &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; error &lt;span style=&quot;color: #000040;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; KErrNone &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// Handle errors&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt; &lt;span style=&quot;color: #666666;&quot;&gt;// Get connection client info&lt;/span&gt;&lt;br /&gt; TConnMonClientEnumBuf buf&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt; monitor.&lt;span style=&quot;color: #007788;&quot;&gt;GetPckgAttribute&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; connectionId, 0, KClientInfo, buf, status2 &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt; User&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;WaitForRequest&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; status2 &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;br /&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; status2.&lt;span style=&quot;color: #007788;&quot;&gt;Int&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000040;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; KErrNone &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;// Handle errors &lt;/span&gt;&lt;br /&gt;    &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt; TUint clientCount &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; buf&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #007788;&quot;&gt;iCount&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;  &lt;span style=&quot;color: #666666;&quot;&gt;//number of clients&lt;/span&gt;&lt;br /&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; TInt i &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt; clientCount&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt; i&lt;span style=&quot;color: #000040;&quot;&gt;++&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;     &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;      TUid uid &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; buf&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #007788;&quot;&gt;iUid&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;    &lt;span style=&quot;color: #666666;&quot;&gt;//UID of the client&lt;/span&gt;&lt;br /&gt;      &lt;span style=&quot;color: #666666;&quot;&gt;//...&lt;/span&gt;&lt;br /&gt;     &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt; monitor.&lt;span style=&quot;color: #007788;&quot;&gt;Close&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #666666;&quot;&gt;// Close RConnectionMonitor object&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Required Capabilities:&lt;/b&gt; NetworkControl
&lt;/p&gt;</description>
			<pubDate>Mon, 23 Nov 2009 09:17:11 GMT</pubDate>			<dc:creator>Forum Nokia KB</dc:creator>			<comments>http://wiki.forum.nokia.com/index.php/Talk:TSS001491_-_Retrieving_the_list_of_applications_using_an_active_connection</comments>		</item>
	</channel>
</rss>