Sunday 17 May 2015

HTML Best Practices

1. Start with DOCTYPE
Bad :
<html>
   <body>
      -----
   </body>
</html>
Good:

<!DOCTYPE html>
<html>
   <body>
     -----
   </body>
</html>
It helps to read and render your markup correctly.

2. Write Standards-Compliant Markup:
don't use the id attributes multiple time
don't omit the closing tags.
close the html tags properly.
Bad :

<p id="intro">properly close  the <strong> Html </p> tags .</strong>
<p id="intro">don't  omit the closing tag.
Good:

<p class="intro">properly close  the <strong> Html </strong> tags </p>
<p class="intro">don't  omit the closing tag.</p>

3. Use proper semantic elements

Bad:
<span class="heading"><strong>Heading</span></strong>
<br><br>
 some paragraph
<br><br>
Good:

<h1>Heading</h1>
<p>some paragraph</p>


4. Specify MIME type

Bad:
<link href="/pdf" rel="alternate">
<link href="/css/style.css" rel="stylesheet">
Good:

<link href="/pdf" rel="alternate" type="application/pdf">
<link href="/css/style.css" rel="stylesheet" type="text/css">


5. Write character encoding
Bad:
<head>
  <title>HTML Best Practices</title>
</head>
Good:

<head>
  <meta charset="UTF-8">
  <title>HTML Best Practices</title>
</head>


6. Avoid div structural elements

Bad:
<div class="container">
  <div class="article">
    <div class="headline">Heading</div>
  </div>
</div>
Good:

<div class="container">
  <article>
    <h1>Heading</h1>
  </article>
</div>


7. Syntax Organized

Bad:
<Aside>
<h3>heading</h3>
<H5 HIDDEN='HIDDEN'>Sub heading</H5>
<img src=sample.png alt="company logo" />
<ul>
<li>list item1</li>
<li>list item2</li>
</ul>
</ASIDE>
Good:

<aside>
  <h3>heading</h3>
  <h5 hidden>Sub heading</h5>
  <img src="sample.png" alt="company logo">
  <ul>
    <li>list item1</li>
<li>list item2</li>
  </ul>
</aside>

8. Don't use Inline Styles

Bad:
<p style="color:red">sample paragraph</p>
Good:

<p class="intro">sample paragraph</p>
keep external css
.intro {
color:red;
}

9. Keep all external style sheets inside head tag

<head>
<title>My Favorites Kinds of Corn</title>
<link rel="stylesheet" type="text/css" media="screen" href="libstyles.css" />
<link rel="stylesheet" type="text/css" media="screen" href="custom.css" />
</head>
The primary benefit is that your pages will load faster.
putting stylesheets in the HEAD allows the page to render progressively
load lib css first.
  • Use a CSS Reset
  • Placing Javascript Files at the Bottom
  • validate html in w3c 
10. Use meaning full title tags.
The <title> tag helps make a web page more meaningful and search-engine friendly. For example, the text inside the <title> tag appears in Google’s search engine results page, as well as in the user’s web browser bar and tabs.
Ex: <title>Welcome To Web Developer's Library</title>

11. Use Descriptive Meta Tags
Meta tags make your web page more meaningful for user agents like search engine spiders.

it will give the whole summary about your webpage or blog.

12. Minify CSS and JS.
we can decrease the size of the file. it means we are removing unnecessary space and comments.

13. Use right elements in right place.

14. Should use alt tag for image

15. Use modular IE fixes.
You should use conditional comments to target IE.
Ex: <!--[if IE 7]>
<link rel="stylesheet" href="css/ie-7.css" media="all">
<![endif]-->

16. Use lower case markup.

17. Validate your code.

18. Write well formatted code.

19. CSS  Exteranal files load in head tag.

20. JS External files load in body tag.

21. Choose good editor to develop the code.

22. For Beginners don't use CSS frame work better use css.

23. Use class instead of id for css, because you are losing benefits of class.

Friday 15 May 2015

Stop writing For loops. Start using underscore

Underscore:

Underscore.js is a JavaScript library which provides utility functions for common programming tasks. It is comparable to features provided by Prototype.js and the Ruby language, but opts for a functional programming design instead of extending object prototypes.

Underscore consists of a little more than 100 functions, which fall under four main categories depending on the datatypes which they manipulate: functions for manipulating arrays, functions for manipulating objects, functions for manipulating both arrays and objects (the name of the category is "Collections") and functions for manipulating other functions. There are also two utility categories : "Utility" and "Chaining".

Example:
for example if we use javascript to achieve some functionality we need to write the  below loop
var i,result = [];
for(i = 0; i < myArray.length; i++) {
  var myObject = myArray[i];
  if(myObject.isAwesome === true) {
      result.push(myArray[i]);
  }
}

The same functionality i can achieve  with underscore.js without loop.

var result = _.filter(myArray, function(myObject) {
  return myObject.isAwesome === true;
})

Underscore Reference : (http://underscorejs.org/)

Thursday 14 May 2015

Hybrid Mobile App Frameworks

Ionic & Angular:

The beautiful, open source front-end SDK for developing hybrid mobile apps with HTML5.

Free and open source, Ionic offers a library of mobile-optimized HTML, CSS and JS components, gestures, and tools for building highly interactive apps. Built with Sass and optimized for AngularJS

Advantages:
  • Open-source and free (under a permissive MIT license)
  • Built around Angular (Ember and Backbone not supported)
  • iOS and Android support (currently only WebKit supported devices)
  • Ionic is built to perform and behave great on the latest mobile devices. With minimal DOM manipulation, zero jQuery
  • Heavily optimized for touch devices (Ionic is focused on building native/hybrid mobile apps rather than mobile websites.)
  • Great command line utility support (Cordova users will recognize the benefit)
  • Optional Sass support
  • Supports Cordova, PhoneGap, or Trigger.io
  • Over 500 custom designed font icons MIT licensed
Built on top of the popular AngularJS framework from Google, Ionic utilizes AngularJS to provide the application structure, while Ionic itself focuses on the user interface. In other words, we see a match between the power of Angular and the beauty of Ionic UI.

Ionic provides a set of Angular directives (custom HTML elements) for it’s own components, making it as easy to use the widgets as writing a line of HTML code. In addition to directives, Ionic uses Angular’s touch recognizers, view animation logic, HTML sanitation, and asynchronous communication.
Ionic reference : ( http://ionicframework.com/)


Mobile Angular UI :

Build HTML5 create interactive mobile apps with Bootstrap3 and Angular JS

Mobile Angular UI is a mobile UI framework just like Sencha Touch or jQuery Mobile. If you know Angular JS and Twitter Bootstrap you already know it!

Main features of Mobile AngularUI
  • Bootstrap 3
  • AngularJS
  • Mobile Angular UI provides essential mobile components that are missing in Bootstrap 3: switches, overlays, sidebars, scrollable areas, absolute positioned top and bottom navbars that don't bounce on scroll.
  • AngularJS modules such as angular-route, angular-touch and angular-animate
  • Mobile Angular UI doesn’t have any jQuery dependencies, all you need are some AngularJS directives to create awesome mobile user experiences.
  • FontAwesome Icons are included by default in place of Glyphicons.
Mobile Angular UI Reference : (http://mobileangularui.com/)


Cordova/Phonegap:

Apache Cordova is a platform for building native mobile applications using HTML, CSS and JavaScript

Apache Cordova is an open-source mobile development framework.

These apps are natively installed on iOS, Android, Windows Phone, Blackberry, Tizen, Firefox OS, and others, all leveraging HTML for the user interface, CSS for layout and styling, and JavaScript for interactivity, dynamism, and interaction with native-OS functionality.

When using the Cordova APIs, an app can be built without any native code (Java, Objective-C, etc) from the app developer

And because these JavaScript APIs are consistent across multiple device platforms and built on web standards, the app should be portable to other device platforms with minimal to no changes.

a mobile developer and want to extend an application across more than one platform, without having to re-implement it with each platform's language and tool set.

a web developer and want to deploy a web app that's packaged for distribution in various app store portals

a mobile developer interested in mixing native application components with a WebView (special browser window) that can access device-level APIs, or if you want to develop a plugin interface between native and WebView components.

Cordova reference Link : (https://cordova.apache.org/)




jQuery Mobile


jQuery Mobile is an HTML5-based user interface system designed to make responsive websites and apps

jQuery Mobile is the easiest way to build sites and apps that are accessible on all popular smartphone, tablet and desktop devices.

jQuery Mobile is HTML5 markup based framework (not like Ionic Framework or Sencha Touch) inonic and scncha touch are built to work only on web kit browsers but jquery Mobile will run on pretty much anything as long it supports HTML5 standard.

jQuery Mobile offers CSS-based enhancements for common user interface elements(like classes, grid layout, responsive grid, theme)

Advantages:
  • Most commonly use, which means a lot of 3rd party information
  • Extremely easy to use, HTML5 bases, just like App Framework
  • Good official documentation.
  • Support every HTML5 browser you can think which makes it good for a desktop and mobile use
  • Excellent theme support
  • Large number of 3rd party plugins 
DisAdvantages:
  •  JQuery mobile apps are slow on mobiles.
  • Avarage UI
  • Every JQuery mobile app appears as a duplicate of the other with no customization.
  • JQuery Mobile does not offer “out of box” MVC support.
  • JQuery mobile, when combined with other mobile frameworks, becomes even more time-consuming.


jQueryMobile reference : (http://api.jquerymobile.com/)