September 25, 2011

Code Improvements in Muse Beta 3

Today we released the Beta 3 update of Muse. Muse enables graphic designers to create professional HTML websites without writing code. Muse has generated an enthusiastic response from the design community with over 260,000 designers downloading it in the first 40 days. We’ve very excited at the number of people who have been participating in our support community, logging bugs, asking questions and giving feedback.

When we announced this technology last month, people in the web community voiced strong concerns about the quality of the code generated by Muse. The Muse team has taken that feedback to heart.  To that end we are very aware the HTML/CSS/JavaScript code generated in the first beta of Muse had lots of room for improvement.

The Beta 3 update includes improvements in two key areas:

  1. Fixes to over 40 bugs discovered by the Muse user community. For a full list of bugs fixed visit muse.adobe.com/beta3
  2. Some initial improvements in the code Muse generates which help reduce page load times and data usage of websites created with Muse.

These improvements to code are a first step in an ongoing process that will continue through the beta and subsequent releases of Muse. Existing Muse sites can be improved by downloading Beta 3 from muse.adobe.com and simply re-exporting the site.

The rest of this post will focus on the details of the code improvements in Beta 3.

How do we evaluate improvements to code?

We are committed to improving the HTML/CSS/JavaScript code Muse generates and evaluate it using several criteria including—

  1. Cross-browser compatibility
  2. Load performance of the site
  3. Search Ranking via SEO
  4. Accessibility and Usability

The primary focus of code improvements in Beta 3 are around cross-browser compatibility and reducing page load times and data usage.

Note: All results are based on tests conducted by the Muse engineering team by comparing Beta 2 vs Beta 3. Tests were conducted using three websites: http://muse.adobe.com, http://www.greenartisans.com and http://www.visualarms.com

HTML Improvements

1. Removed duplicate HTML in IE conditional comments

Certain designs created with previous beta versions of Muse had duplicate markup in Internet Explorer (IE) conditional-comments. This was clearly an inefficient way of achieving cross-browser compatibility in IE. Designs that use rounded corners, transparency on fills (rgba) and transparent png triggered this behavior resulting in duplicated markup, CSS, text content and in some cases even images.

For Beta 3 we’ve removed the duplicate IE markup and standardized on single markup for modern browsers, relying on HTML5 cross-browser poly-fills for legacy browsers.

Beta 2 Output

HTML snippet from Beta 2 – markup for modern browsers

HTML snippet from Beta 2 – markup for modern browsers

HTML snippet from Beta 2 – duplicate markup for IE8 and below

HTML snippet from Beta 2 – duplicate markup for IE8 and below

HTML snippet from Beta 2 – additional CSS file for Internet Explorer

HTML snippet from Beta 2 – additional CSS file for Internet Explorer

Beta 3 Output

HTML snippet from Beta 3 – single markup for all browsers; IE handled via poly-fill

HTML snippet from Beta 3 – single markup for all browsers; IE handled via poly-fill

HTML snippet from Beta 3 – eliminated CSS for Internet Explorer

HTML snippet from Beta 3 – eliminated CSS for Internet Explorer

What was the impact of this change?

Total size in Kb of HTML and CSS files
Site Beta 2 Beta 3 % Difference
muse.adobe.com 2807 2296 -18%
visualarms.com 493 220 -55%
greenartisans.com 554 220 -60%

From Beta 2 to Beta 3 the savings in files size are 18%—60% depending on the design.

Total number of CSS and image files
Site Beta 2 Beta 3 % Difference
muse.adobe.com 242 242 -0%
visualarms.com 124 84 -32%
greenartisans.com 396 198 -46%

From Beta 2 to Beta 3, the number of CSS and image files are reduced 0%—46% depending on the design.

2. Removed empty divs for clearing floats

Muse uses HTML floats for representing complex layouts, groups and widgets.  The older implementation used an empty div to clear floats so its parent container would stretch to contain the floats.  This clearly resulted in numerous unnecessary empty divs leading to code-bloat. We’ve replaced this in Beta 3 with a more modular approach to float management using the :after pseudo-element.

HTML snippet from Beta 2 – empty “wrap” div used to clear floats

HTML snippet from Beta 2 – empty “wrap” div used to clear floats

HTML snippet from Beta 3 – modular float management using clearfix

HTML snippet from Beta 3 –modular float management using clearfix

3. Reduced extra nested divs

We took some steps to remove extra nested divs not required for layout to simplify the structure and reduce size of the HTML. There are clearly more avenues for savings in the future.

What was the impact of removing empty divs and extra nested divs?

Number of DOM elements on index.html page
Site Beta 2 Beta 3 % Difference
muse.adobe.com 349 247 -29%
visualarms.com 977 906 -7%
greenartisans.com 277 215 -22%

Between Beta 2 and Beta 3 the number of markup elements were reduced 7%—29%.

4. Using anchor tag as blocks

When hyperlinks are applied to block elements, Muse Beta 3 exports <a> tag as block, taking advantage of this feature in HTML5. This change results in better usability of hyperlinks such as allowing users to right click and copy the link address or open the link in a new tab etc.

CSS Improvements

5. Removed redundant CSS

There were many cases in Beta 2 where Muse generated redundant declarations for CSS properties such as border-radius. We’ve also removed many duplicate CSS properties generated for a:hover selector. This change reduces the size of the generated CSS.

6. Shorthand CSS properties

In Beta 3, Muse now exports shorthand CSS properties such as border-radius, border, margin, padding and background when possible, resulting in more compact CSS.

7. Shared CSS

CSS rules that are shared between pages have now been moved to a global style sheet shared across the site. This decreases the size of CSS files for individual pages and allows browsers to cache the site global sheet.

What was the impact of the changes to CSS?

Total size in Kb of CSS files
Site Beta 2 Beta 3 % Difference
muse.adobe.com 1321 947 -28%
visualarms.com 244 96 -61%
greenartisans.com 249 95 -62%

From Beta 2 to Beta 3, the total size of CSS files are reduced 28%—62% depending on the design.

JavaScript Improvements

Many of the JavaScript changes made in Beta 3 enable better progressive rendering of pages and allow for greater download parallelization in the browser, thereby improving page load time.

8. Moved JavaScript from document head to end of body

With Beta 3 we’ve moved most JavaScript not required before the DOM loads from the document head to just above the end of the document body. This includes external JavaScript files and calls. This change speeds up initial rendering of the page because browsers will no longer wait to synchronously parse JavaScript before rendering the page. See move scripts to the bottom for details.

9. Combined external JavaScript files

Many JavaScript files are now combined to reduce number of http requests and size of download. This improves page load performance. See combining external JavaScript for details.

10. Reduced inline JavaScript

Reduced unnecessary JavaScript calls when multiple widgets were used on a page. Now regardless of the number of widgets on a page, showing them is taken care of by just one call to reduce size of generated JavaScript.

11. Widgets appear sooner

Most Muse widgets will now appear before the page DOM fully loads allowing users to interact with widgets such as menus sooner.

Miscellaneous

12. Exported file names

Exported file names are now always lowercase. This avoids problems due to differences in case-sensitivity of filenames between web servers.

What Next?

We recognize there are numerous opportunities for continued improvement. Beta 3 focused on cross-browser compatibility and page load performance. We’ll continue to work on those areas, in addition to search ranking/SEO and accessibility for future releases. Stay tuned!

Muse Engineering Team

7:00 PM Permalink