Make Transition From Javascript Evolution To Cross Browser

2

I see this need, which people like me self-taught, try to understand.

The question is - Nowadays some features are already supported by the main browsers HTML5, CSS3, DOM, APIs and ECMAScript ... being very Javascript , is not my case, but you can be one of them. However, I always come across some answers here using them.

There is always a need to transition (transcribe) this feature (s) to some compatible method . But as I am always an apprentice, today, I open an issue indifferent to the others made by me.

The idea here is to give a list of comparisons of what can be replaced by another native JavaScript method, in the absence of browser support.

Example

In HTML 5, we have as native praceholder for text field. It clears the text set in value when in focu .

This same effect can be achieved with pure Javascript as follows:

 <input value="digite aqui" type="text"
 onblur="if(this.value == '') {this.value = 'digite aqui';}" 
 onfocus="if(this.value == 'digite aqui') {this.value = '';}" />

In short - it means using Javascript's own method and properties instead of elegant APIs and such.

  

I think HTML5, CSS3, DOM, APIs and ECMAScript ... in a general way would be best applied to a specific project (APP) and / or given device, such as Android user, Windows Phone or iOS, but not for a whole as the Web, remembering that not all have fast and state-of-the-art computers, and over time Firefox, Google Chrome, Opera and Safari among others less, update their browsers periodically, given that we have to make a Purchase of a new Micro Computer, because the new upgrade can no longer run on the old PC, sometimes neither install.

As far as NGOs, nonprofits are concerned, they can not afford to buy a new appliance, they survive on donations, right?

Oh, I'm on the stage. If I am developing a Web project and wish to impact the greater number of Internet users in contact with the site / blog, how will I give up Cross Browser language . I can not!

If anyone understood the question leave your answer or comment.

    
asked by anonymous 30.06.2016 / 18:14

3 answers

2

You're going the other way. Think about the user first (read: audience) then define the technology.

  

Do you want to deliver software to NGOs in remote places that have precarious equipment, slow internet and little technologically trained personnel?

Do not use advanced features. Think of pure HTML without much freshness.

  

Are you making software to be used by clients of a bank, so security is a concern?

Strictly defines which browsers and which versions can be used and use the features available on them.

  

Are you making a website for the web in general (news, recipes, etc.)?

Review the site user profile.

Google Analytics, for example, provides graphs that show the percentage of users who access your site from each browser, desktop / mobile, etc. You can then focus, for example, on writing code that is compatible with 95% of the browsers in that report.

The other 5%? They will probably have a partial use and will have to have patience.

Filling in the gaps

When defining the list of supported browsers, you can basically adopt three strategies for each feature you need to use:

  • Use the features available in the newer versions and leave the feature out of the older versions. It would be the case of having the placeholder in Chrome, but not in certain versions of IE, for example.
  • Use the features of the new versions and provide shims or polyfills , which simulate those features using some magic.
  • Rely on older versions and only use the features that are available in all browsers.
  • Option # 1 is interesting because it benefits those who have the newest browser. Who does not, does not see the functionality better, but manages to use the site without problems. They will not be upset, for "what the eyes do not see, the heart does not feel" . : P

    Option # 2 provides the same advanced features for everyone, but it involves more work and will probably slow down the site to load, as there are additional scripts to handle the extra work the browser does not do. / p>

    Option # 3 is the safest, but it can negatively impact the user experience.

    The decision

    It's up to you - or the project's architects / leaders, or the person who decides if it's going to pay you more or less for the job. :)

    The important thing is to know that all the options, or a mixture of them, are valid for different contexts.

        
    01.07.2016 / 05:55
    4

    From what I understand of your question, you would like a list of features and which browsers (with version being said) that functionality is implemented. There is a website that does just that, even it says even if a feature is partially implemented.

    link

        
    30.06.2016 / 18:45
    3

    Diego, I know it's important to support the largest possible share of users, while it's difficult to maintain compatibility with legacy browsers.

    An example of this dilemma is jQuery itself, which for some time maintained two versions, 1.x and 2.x, the main difference between them being support for versions of IE that are even more maintained by Microsoft .

    But keeping this type of compatibility has its price, version 1.x of jQuery is larger and heavier than version 1.x, as a result it requires more time to be downloaded and more processing of the client.

    In this case it's really worth penalizing ~ 96% of users because of the remaining ~ 4%, please be aware that neither% nor% of% supports Microsoft and will only support the latest version ( IE 6~8 or Edge , depending on the OS).

    So I advise you to draw a line and define the minimum version of each browser you plan to support.

    Now let's go to the IE 11 question, so before using features , you should check that it is compatible with the minimum browser version that you have set a little, and if it is not compatible, you should take the decision, give it up or add a feature script.

    In my opinion, the best way to implement a polyfill script is to create a Polyfill , at the beginning of it, make a detection of IIFE (Immediately-invoked function expression) , if it is not found, then implement it.

    Example, you decided to support feature and found it cool to use IE9 on your site, but found that it does not support it, in which case you will have to give up tag template or use a <template> so that your system understands this Polyfill .

    Here is an example of tag for Polyfill tag of HTML5 taken from the following repository .:

    (function () {
      if ('content' in document.createElement('template')) {
        return;
      }
    
      var templates = document.getElementsByTagName('template');
      var plateLen = templates.length;
    
      for (var x = 0; x < plateLen; ++x) {
        var template = templates[x];
        var content = template.childNodes;
        var fragment = document.createDocumentFragment();
    
        while (content[0]) {
          fragment.appendChild(content[0]);
        }
    
        template.content = fragment;
      }  
    })();
    
        
    30.06.2016 / 18:46