A web developer recently wrote to me, asking for help with a web page
that loaded 10x to 20x slower in mobile browsers (including both Firefox
and Chrome) compared to the exact same document in desktop browsers,
even when running on high-end tablets over the same fast wi-fi network.
Looking for resources on mobile web performance optimization, I found a
lot of articles but many were conflicting or out-of-date, and none
mentioned mobile Firefox.
MDN has only a single paragraph about performance for mobile web
development, with a link to a generic list of recommendations from Yahoo:
https://developer.mozilla.org/en-US/docs/Web_Development/Mobile/Mobile-friendliness
It would be great if we could produce a good article with
mobile-specific performance tips for web developers, including ways that
our tools can help, and any important performance differences between
desktop and mobile browsers. Below is the main part of my reply to the
webdev who wrote me, which I hope includes some useful things for such
an article. However, I'm not really up on the latest data or best
practices for mobile performance. Any resources I should add? Anyone
want to volunteer to help out with this?
-------- Original Message --------
Firefox and Chrome both include built-in tools that can help you
diagnose slow page rendering. In particular, Firefox's Network Monitor
will display a precise timeline of when each network request on your
page happens, how large it is, and how long it takes:
https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor
If your page contains JavaScript code that is taking a long time to run,
the JavaScript profiler will pinpoint the slowest lines of code:
https://developer.mozilla.org/en-US/docs/Tools/Profiler
You can use these tools with the Android browser by running Firefox or
Chrome on a PC and enabling remote debugging:
https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging
https://developers.google.com/chrome-developer-tools/docs/remote-debugging
Using the YSlow and FireBug add-ons together will also provide extremely
helpful recommendations for improving performance. They run in desktop
Firefox, but the problems and solutions they identify will be especially
useful for mobile browsers. You should definitely run YSlow and follow
its recommendations:
https://addons.mozilla.org/en-US/firefox/addon/yslow/
In particular, making a large number (dozens or hundreds) of network
requests can take longer in mobile browsers. Rendering of large images
or CSS gradients can also take longer. Simply downloading large files
can take longer, even over a fast network, because mobile hardware isn't
always fast enough to utilize all the available bandwidth. This
presentation has some general tips for mobile web performance, and I'll
try to see if I can find any other good documents about best practices:
http://www.slideshare.net/firt/mobile-web-high-performance
If the Firefox and Chrome developer tools don't help you find a problem,
or if they seem to indicate that the problem is caused by the web
browser, then we can help you figure out more if you provide a test case.
* See if you can reproduce the problem by saving and loading a static
copy of an HTML page (including any images/stylesheets/scripts it
embeds). If that works, you can then edit the static files to
remove any private information, then send them to me, or attach them
as a .ZIP archive to a bug report in
https://bugzilla.mozilla.org
(and put my email address in the CC field).
* If that doesn't work, then perhaps you can host a test case on your
server and give us access to it. Send a link to the test case to me
or file it in a Bugzilla bug.
Or if you would like to help even more, you can install our "Nightly"
development build and run the Gecko Profiler while loading your page.
This will provide detailed information about which parts of the browser
code are running slowly while the profiler runs, which you can then send
to us for analysis. This requires installing Android developer tools
and is a bit tricky, but we can help out if you are interested in trying
it. (We can also do this ourselves, but if you are willing to do it
then it will help us get results faster.)
https://developer.mozilla.org/en-US/docs/Performance/Profiling_with_the_Built-in_Profiler