There've been a lot of talk about mobile web development, and since I've been doing mobile web recently, I thought it would be useful if I can post some findings here.
Firstly, mobile web is not iPhone or iPad only. In fact, a fair share of smartphone users are non-iOS users. However, catering to every mobile phone in the world is impossible too, not without major design sacrifices.
Think about this, for iOS devices alone, you've got to cater to the retina display, and the device orientation changes. Not to mention the various iOS versions that support different features.
Simply put, no matter what you do, one design/code will not fit them all.
These findings are purely of my own opinion though, and many would probably disagree with me, but I find that perhaps, we should really spend our time and effort on smartphone users. Not just any smartphone users though, specifically - any device with at least 320 pixels in width in the portrait orientation.
So, having said all that, here are some quick findings:
- On iOS devices, there's a bug that scales the device view when the orientation changes, make sure you apply this handy fix to all your mobile web pages to avoid that.
- Make sure you insert your meta tags.
meta name="viewport" content="width=device-width, initial-scale=1.0"
- Remove the Safari address bar with this line of code:
meta name="apple-mobile-web-app-capable" content="yes"
You might also need this piece of Javascript to make sure the page does scroll up.
window.addEventListener("load",function() {
// Set a timeout...
setTimeout(function(){
// Hide the address bar!
window.scrollTo(0, 1);
}, 0);
})
- Use CSS Media Queries to cater to orientation changes.
@media only screen and (orientation: landscape) { //insert css here }
- Use responsive images. If you're using css background-images, use this line of code to make sure the background-image scales.
background-image: url('img/image.jpg');
background-repeat: no-repeat;
background-size: 100%;
- Always minify your js and css to decrease file sizes.
- Test in as many devices as you can. At least have a Mac installed with the iOS Simulator that can go back and forth between various iOS versions.
- Lastly, optimize your images. If you can, load the retina-images only if the user is using a retina-display.
That's all I have for now, I'll update with more findings if possible. Please leave a comment if you have something to change or a better way to do something.