We all know that script is blocking element, meaning no content will be rendered untill script block is parsed and executed or downloaded then parsed and then executed in case of externale script.
And we were told endless times that the best practice is to load scripts at the end of web page. It’s true.
We also have document.ready events thanks to numerous javascript frameworks that gives us opportunity to perform most of our JS actions when document is ready to be manipulated. But there are cases when you do need JS blocking features.
Read more…
VN:F [1.9.3_1094]
Rating: 5.0/5 (2 votes cast)
I have two simple questions for you about boolean values in Javascript.
When will browser show alert message:
if (a-b) alert("it's true!");
And another one
Read more…
VN:F [1.9.3_1094]
Rating: 5.0/5 (5 votes cast)
This post is somehow related to my previous post about javascript function context. Recently I helped one of my friends to debug a very funny problem. He told me that his inline event handler doen’t work, because he could not pass this object to his function.
You probably wonder what did I find? 
Read more…
VN:F [1.9.3_1094]
Rating: 4.6/5 (5 votes cast)
How many times you had problem or were asked about what happened to this object in your function? Or why this is not an object you expect it to be? Probably these times you have to remind yourself or your fellow programmer about function context.
First of all I have to ask you all a pretty lame question. If you write function in JS block right inside your HTML, what this keyword will refer to?
<script type="text/javascript">
function testThis(){
//who is "this"
}
</script>
And now to the real example.
Read more…
VN:F [1.9.3_1094]
Rating: 4.9/5 (8 votes cast)
Recent Comments