10 Simple Tricks for a Web Developer

There is a saying that “No matter it is either Ballroom or Battlefield, Princesses always be prepared before entering into it“, similarly, every web developer must be prepared by knowing the pros and cons before writing a code. Here are the few tricks which will be helpful in the preparation –

  1. Always put <meta> tag with viewport element and set the content as “width=device-width, initial-scale=1.0“, this comes in rescue if the site has been opened in any device like mobile phone, ipad and initial scale is for zooming purpose.
  2. <!DOCTYPE html> is necessary for every HTML page, this make a page valid and also tells the web browser that what kind of document to load.
  3. CSS should always preferred to be external if a change has to be done to multiple pages because it reduces the load time and file size also can be reduced. The priority of the inline, internal and external CSS  is in increasing order.
  4. Whenever code doesn’t work, always debug it using console, short cut for console is Ctrl+Shift+J , this seems to be a super hero for many programmers. Sometimes, all you need to do is just refresh the page, to see the changes.
  5. Minify the code as much as possible, this helps in communicating with  a server and loading a page pretty faster. This is just achieved by removing extra spaces and extra lines, there are many online tools for this job.
  6. Whenever you write a JavaScript code, always check the code in JSHint or JSLint, this helps in saving time and also knowing the errors pretty easier way.
  7. While writing a  jQuery code, using noConflict() to have a customize variable in the place of regular $ or long jQuery will be helpful in letting $ be used in other scripts. For example, AngularJS uses $ for scoping variables inside controllers.
  8. Use JavaScript Task Runners, generally people use GRUNT or GULP for this. This just automates all the process of minifying, linting, testing a code.
  9. Always make your website responsive, these days people equally use their mobile phones or ipads like they do use a computers. @media queries in CSS3 will be very helpful in scaling a website by setting minimum or maximum width or height.
  10. Between id and class, tags with id have more priority than with class. There can be many tags with same class but there should be only one tag with an id.

Leave a comment