Why browsers show pages differently




















Always reach the author's instructions carefully before attempting to use one! You might think this sounds wonderful! Why worry about what feature different browser support, if you can just fill in support for the ones that don't using JavaScript? The trouble is that using a Polyfill does add weight to a page, both in terms of extra files requiring download, and extra processing required to put the polyfill in action.

If you used loads of polyfills on every one of your pages, they would likely be significantly slower to download and run, as well as making your code base a lot more fiddly and complex. You might be thinking at this point "well isn't there a way to only load those extra resources if the browser really needs them?

The general idea is to do feature detection to see if the browser supports those features, and then pull in a polyfill or un some alternative code only if needed. The easiest way to do the feature detection part of this is through a feature detection library called Modernizr. This is a JavaScript library that provides an easy way to do pretty much all of the feature detection you could need. All you have to do is.

Let's look at these two aspects in more detail. They will look something like this:. This is really powerful, as it allows you to apply CSS to the page selectively, depending whether it supports certain feature or not.

For example, if your code uses an animated 3D transform by default to reveal some content underneath:. You can include alternative styling that overrides this in browsers that don't support 3D transforms like this:.

It might not look quite as elegant, but it would still produce an ok experience that allows access to the underlying content. For example, if you wanted to query whether the current browser supports 3D transforms in JavaScript, you would write if Modernizr. So you could have a block of code like this:. However, you can customize Modernizr and create a version suitable for your site that only contains the tests you need, which cuts down on the file weight.

And even though you can't feature detect everything, you will find it invaluable in many situations. Now we've covered the feature detection side of things, lets cover what we can do to load resources like Polyfills only when you need them. To help you out with this, Modernizr comes packaged with a really smart, dandy little utility library called YepNope.

This can do a lot, but in a nutshell, it allows you to specify a test of some kind, and then say what happens when the test is passed, and when it fails.

Here's a simple example:. So basically, you are sating what the test is, then saying that if the test is passed, just load the normal script, but if the test fails, load the normal script and a polyfill to allow the code to work in an older browser. I hope that's helped you get all these ideas clear in your head — why browser sniffing is bad, why feature detection is a much better way to detect whether a browser will run your site features or not, and different strategies for providing different capability browsers with different but acceptable experiences.

One area where sites almost always look different is on pages with forms. Different operating systems and browsers render the buttons on forms and text boxes completely differently. On a PC, default submit buttons are square and pretty flat looking, on a Mac the default submit buttons are nicely shaded ovals with a gradient.

For example, a submit button can look like a gray rectangle on your Windows Classic theme, and like an oval if you use the XP style. As a workaround, you can create custom buttons for your website. What is Browser Support? Why do browsers display pages differently?

This can lead to inconsistent interpretations between browser manufacturers. Like all software, browsers have a lifespan and fall out of date. Most modern browsers automatically update so this is becoming less of an issue. This is common for old versions of Internet Explorer. What does browser support mean? Send Message. Subscribe via email Sign up to get notifications of new posts by email. Other posts you might like.

Responsive Designs vs. Traditional Builds 7th August by Aaron Brady. Call us on Our friendly Magento experts are happy to answer your questions. Follow us! Get the latest eCommerce news, reviews and expert advice in your inbox. To make matters worse, there can be issues with a website in different versions of the same browsers. For example, if Chrome adds a new standard to their engine it may break a website that was once working in Chrome.

Developers have to try and catch these changes and update their websites before the customer notices the problems. All of this will cause hiccups in functionality; however, FIS provides access to several browsers to combat this problem.



0コメント

  • 1000 / 1000