Minification is the process of removing comments and unnecessary whitespace from a program. Depending on how the program is written, this can reduce the size by about half.
for example Continue reading “what is minification?”
Minification is the process of removing comments and unnecessary whitespace from a program. Depending on how the program is written, this can reduce the size by about half.
for example Continue reading “what is minification?”
prerequisites
A short tutorial on, how to use yuicompressor is available on https://www.npmjs.com/package/yuicompressor
Here is a small javascript program which helps you to compress multiple files. Continue reading “how to minify multiple javascript files using yuicompressor node module”
JSFIDDLE: http://jsfiddle.net/jnelsonin/ctfy158o/
This simple formula will help you to convert a px value in CSS to corresponding em, % and pt.
1 2 3 4 5 6 |
pt = (px * 3 ) / 4; em = pt / 12; % = (pt / 12 ) * 100; ie; % = em * 100; |
consider we have a pixel value of 8. Based on the above formula,
pt = (8 * 3) / 4 = 6pt
em = 8 / 12 = 0.5em
% = 0.5 * 100 = 50%
[table id=6 /]
You can donate blood if
Do not donate blood if you have any of the following conditions: Continue reading “Dos and Don’ts for Blood Donation”
In Interner Explorer, When we bring the focus to a select element, the element gets highlighted with a blue background, like in this given image. This is the default bahavior of Internet Explorer browser to indicate that, the focus is on select element.
How can we remove this highlighting?
Pure CSS method
1 |
select::-ms-value {background: none; color: #42413D;} |
jQuery method
1 2 3 |
$('option').click(function() { $('#select').blur(); }); |
JSFiddle: http://jsfiddle.net/jnelsonin/NMq75/
This is how the select element looks in FireFox and Internet Explorer 10, after giving a background image.
In three different methods you can set multiple style properties to an element using javascript.
for example, consider, you want to apply colour, border colour and visiblity to an element with id myElement
Method 1
1 2 3 4 5 |
document.getElementById("myElement").style.color = "#000"; document.getElementById("myElement").style.borderColor = "blue"; document.getElementById("myElement").style.visiblity = "visible"; |
Method 2
1 |
document.getElementById("myElement").style.cssText = "color: #000; border-color: blue; visibility: visible"; |
Now, the above step is going to replace the existing inline style. If you want to keep existing inline style and add these styles additionally, here is the trick
1 |
document.getElementById("myElement").style.cssText +=';'+ "color: #000; border-color: blue; visibility: visible"; |
Method 3
1 |
document.getElementById("demo").setAttribute("style", "color: #000; border-color: blue; visibility: visible"); |
To check if a Javascript function exists before calling it, try this:
1 |
if(typeof functionName == 'function') |
If you want to reduce the number of strings hanging around in your code, try this instead
1 |
if (typeof(possibleFunction) == typeof(Function)) |