Skip navigation

Tag Archives: tips


Problem:
JavaScript can be loaded dynamically on the fly to improve the performance of the page. Basically it is used as lazy loading without blocking other important content of the page.

Here is the code snippet

//
//
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", "myscript.js")
if (typeof fileref!="undefined") document.getElementsByTagName("head")[0].appendChild(fileref)
//
//

One issue with this approach is that you can’t see myscript.js in chrome’s sources tab if you want to debug.

Solution:
Place a comment at the end of the script like below
//@ sourceURL=myscript.js

Reference:
https://developers.google.com/chrome-developer-tools/docs/javascript-debugging#source-maps

Hope this helps.

Advertisements

Few CSS tips

  1. @import delay page load. use <link> instead
  2. Don’t include unit for zeros.
  3. Avoid padding/border and fixed width.
  4. Use IDs for structural elements. let .net use ID’s happily!!
  5. Name ID/classes based on its function never for its appearance.
  6. Dont use short names; use full descriptive names
  7. HTML attributes “id” and “class” are case sensitive! so always use lower case for naming
  8. It is better to use reset browser stylesheet.
  9. Use relative font sizes
  10. Inline styles are only for testing.
  11. css style order:- a:link, a:visited, a:hover and a:active (LoVe HAte)
  12. Don’t use <br />; instead use <p> with margin & padding.
  13. Use tags appropriately like <blockquote>, <cite>, <h1>…<h6>, <strong>, <em>, etc
  14. Don’t use html comments inside external css because it lead to  misinterpretation (child selector >)

Your thoughts??