Archive for the ‘Webtechnology’ Category

1 Comment

Why aren’t CSS colors the same? `in-browser` and `cross-browser`

Thursday, March 15th, 2012

When you set backgroundcolor of the body to hsla(20,30%,50%,.5), what do you expect as output when you read it out with javascript?

The same result in every browser?
Wrong!

The same  in a particular browser ?
Wrong!

The same in a particular browser  indifferent to the color model (rgba or hsla)?
Wrong again! Only Firefox does it right.

Chromium 17: body { background-color: rgba(166, 115, 89, 0.496094); } 

Opera 11.61: body { background-color: rgba(166, 115, 89, 0.5059) } 

Firefox 10.02: body { background-color: rgba(165, 114, 89, 0.5); }

Example

Setting and reading out the color value a 100 times doesn’t change the color in the end, so it seems a result of the javascript floating-point arithmic quirk without any serious implications.

No Comments

Cross-browser CSS transition problems

Tuesday, February 28th, 2012

The great CSS compatibility tables of PPK show good cross browser support for transitions on the width or height property.

Actually the reality is different, there are problems and they are related to height/width changing from percentage/number to another value, from number to percentage and vice versa and most problematic to auto,

You can’t make transitions to height auto, which is IMHO plain stupid. Maybe there are reasons like that the value `auto` is unknown and has to be calculated first. Still, you can read out the property height as a value and  it’s the thing you want as a webdeveloper and it worked in some earlier versions of Chrome if I recall correctly.

Furthermore in the following example the animation renders differently in different browsers.

The latest Firefox (10.0.2) can animate from numbers to percentage. Opera and Chrome can’t, Firefox 9 couldn’t.

No browser can animate to a value auto, which is IMHO we want all.

No Comments

CSS vendor prefix issues

Thursday, February 16th, 2012

Vendor prefixes are the verbose code you see in new `HTML5` sites, in which browser vendors test their new CSS3 rules, when specs are in proposal time or under development.

Something like:


-o-transition: opacity 1s ease-in 1s; //opera
-moz-transition: opacity 1s ease-in 1s; /firefox
-ms-transition: opacity 1s ease-in 1s; // internet explorer
-webkit-transition: opacity 1s ease-in 1s; // safari , chrome
-khtml-transition: opacity 1s ease-in 1s; // konquerer , linux
transition: opacity 1s ease-in 1s; // all when it's official spec

The problem is that most developers seem to do just this:

-webkit-transition: opacity 1s ease-in 1s; // safari , chrome

So they only support webkit browsers and that is plain dumb. At least you should always add the rule without any prefix. That means eventually it will work in every browser that supports it.
Typing all the rules is a pain in the ass, so most developers only do webkit, probably also because Apple invented quite a lot for transitions etc. At that time it was not supported by any other browser, so why on earth should you add code that has no meaning. Well because you care about the future and care about different minded people.

Two helpful solutions

First there are macro’s for IDE’s to type one rule and auto generate the other ones. Here is a CSS vendor prefix macro for Netbeans. Not much of a hassle.

Secondly you can call userJS to the rescue, userJS is like userCSS a rather underestimated part of the internet, but yet a very valuable one. It let you overrule CSS rules or run own JS in websites.

For Opera add this as a userJS:

opera.addEventListener('BeforeCSS', function(userJSEvent){
userJSEvent.cssText = userJSEvent.cssText
.replace(/-(moz|ms|webkit|o)-(border|text-overflow)/g,'$2')
.replace(/-(moz|ms|webkit)-(gradient|transform|transition)/g,'-o-$2');
}, false);

Source here

It will automatically rewrite all -webkit- rules to -o-  rules in Opera, so all the webkit  demo’s will start to work. (if Opera supports them)

Caveats

  • Code (css specs) can change during development.
  • Implementations differ between vendors.

Of course these are workarounds, I still think developers should add all vendor prefixes to their code. It can be automated in an IDE like with mentioned macro for Netbeans or in deployment.

No Comments

Smartphones can be stupid too, and that makes Apple Evil BTW

Wednesday, February 15th, 2012

Why can’t the iPhone / iPad download files?

The standard mobile Safari cannot download all types of files. It can only download files of the type : Word, Excel, Powerpoint and PDF files.

Why on earth does a company design a browser that cannot download files. That is a disgrace, and an insult to the way internet works. It’s getting more smelly, when you realise it can download Office files from one specific vendor Microsoft but not from any other. That isn’t exactly treating people the same, that isn’t exactly improving competition. That’s an insult to the free world. That is limiting competition. That’s anti-competitive behaviour. And it’s simply unfair. We should use open standards in communication, we want to communicate in a way everyone can understand, or at least everyone can learn to understand for free, well that is by investing time, but not money.

Apple has created a phone that can only shop in their own shops, you can’t buy downloads somewhere else. ( iPhone/iPad allows customers to access the iTunes Store to download audio and video files, AR 2010)

(more…)

No Comments

Don’t do Evil

Thursday, January 26th, 2012

AKA the day I stopped using Google. I don’t like the new policy of Google by pushing other services, like Google + to any Google account. It seems that I have a Google website now as well.

The day I started Google I can’t exactly recall, must be back in the 90’s, at least it feels that way, a  friend asked me which site I normally used for search the internet. AskJeeves, Lycos, Hotbot or AltaVista. He said, try Google it’s clean and very fast. I tried it, liked it, and started it using form that day on.

Since then I tried Yahoo a couple of times, but no good. Yahoo doesn’t seem to have heard of the Levenshtein function, so it never corrected my typo’s which is , considered my bad typing, invaluable for any search engines. I always wondered why only Google implemented it.

MSN, Live or Bing has never been an option to me, since Microsoft started accidentally / deliberately  blocking competitors.

This year Google broke my spatial keyboard navigation in my Opera browser. Google made a kind of key-logger from their homepage, every key I accidentally hit on my computer is sent into the search box and up to the Google servers. I can’t move focus of the search-box, so the walk through the several links with Opera’s superb keyboard handling is borked.

And I got sick of all that Javascript running, I got sick of all the cookies that personalized my search results. I live in Amsterdam, but I prefer to have the same view on the world as someone in London, Moscow or New Delhi.

Is DuckDuckGO the way to GO? At least their privacy policy is better.

10 Comments

How to disable CSS transforms, transistions and animations

Thursday, January 12th, 2012

Sick of too much eye-candy and is your browser slowing down due to all the shiny and inappropriate animations?

What don’t you disable all the CSS3 animations, CSS3 transforms and CSS3 transitions with one click and speed up your browsing experience!

Put this in your User-CSS stylesheet:

* {
/*CSS transitions*/
-o-transition-property: none !important;
-moz-transition-property: none !important;
-ms-transition-property: none !important;
-webkit-transition-property: none !important;
transition-property: none !important;
/*CSS transforms*/
-o-transform: none !important;
-moz-transform: none !important;
-ms-transform: none !important;
-webkit-transform: none !important;
transform: none !important;
/*CSS animations*/
-webkit-animation: none !important;
-moz-animation: none !important;
-o-animation: none !important;
-ms-animation: none !important;
animation: none !important;
}

Now you can check with one mouse click if animations or transforms on a page are javascript or CSS driven.

Easy debugging!

Update Nov 2017

Nowadays browser-prefixes can be dropped. And  XFCE Mouse made a comment to include ::before and ::after,which will stop animation in more cases.

*, :before, :after {
 /*CSS transitions*/
 transition-property: none !important;
 /*CSS transforms*/
 transform: none !important;
 /*CSS animations*/
 animation: none !important;
 }

Update Oct 2018
Thx tommasz86, indeed a star is not needed for pseudo-elements :after and :before. Should parse a little faster now ;). I agree commenting out transform is appropriate in most cases.

Still amazed this little user-style can save 40% CPU in Firefox 62 on pages with code like this:

.loader, .wheel {
background: url("../images/loader.svg") center center no-repeat;
webkit-animation: rotating 1.2s linear infinite;
animation: rotating 1.2s linear infinite;
}

Even when the .loader animation is not visible anymore!

Where are the days of good old Norwegian Opera (Presto) browser that could disable animations (including animated gifs) with a mouse click?