JavaScript Code Smells by Elijah Manor

4 07 2015

Advertisements




JSLint and JSHint helps to avoid terrible mistakes in JavaScript code

21 02 2015

Smashing Magazine and JavaScript Weekly are reminding all JavaScript coders that there are tools to validate the code: JSLint and JSHint. Those who are accustomed to compiled languages will find it helpful. But not only those…

Read Article at: http://www.smashingmagazine.com/2015/02/18/avoid-javascript-mistakes-with-static-code-analyzer/





JavaScript popularity rises! According to StackOverflow and GitHub

7 02 2015

Take a look at the report chart from http://news.dice.com/2015/02/04/javascript-tops-popular-languages-as-swift-rises/:

Screen-Shot-2015-02-04-at-9.33.55-AM

There is as many question tagged ‘JavaScript’ as ‘Java’. Both languages are of similar popularity on GitHub as well.

The Swift language is quite popular, concerning its one of the youngest on this chart. PHP still on top. Wonder how many new projects are created in PHP as a well thought choice and how many of them are just in maintenance phase.





Do JavaScript the right way

4 01 2015

Here are some great resources about JavaScript code style, best practices and tips and tricks. Worth to get familiar with them:





Web development done well: WordPress web coding standards

11 10 2014

We all know that mess that grows in CSS, JavaScript and HTML files. There is no compilers as in static typed programming languages that will keep you from doing that mess bu there are Clean Code standards.

The team working on files should keep common standard and follow best practices. It is a failure if each team member has his own preferences and style and writes his parts with his own conventions. WordPress recommendation is:

"All code in any code-base should look like a single person typed it, no matter how many people contributed." – Principles of Writing Consistent, Idiomatic JavaScript

WordPress has its standards. Due to its opensource nature these are vital to keep an order in their web templates and sources. I follow most of their recommendations:





jQuery: prevent copying elements from webpage

4 10 2014

Want to prevent users copying text or images on your website? Or maybe you need to add custom behaviour on Ctrl+C click event?

With jQuery you can intercept the event of copying, pasting, cutting or dragging & dropping the element on your webpage.

Prevent copying

In my case I needed to prevent copying images on webpage (the whole body). This is the method I call on document.ready callback:

var preventCopyPaste = function(){
	$('body').bind('copy paste cut drag drop', function (e) {
   		e.preventDefault();
	});
};

If you need any other custom action to be performed instead of preventing default behaviour, just implement it in method body.

Test it!

Try to copy any image from karomile.com, where I used this method. If you manage to do it – let me know how you did it. I’ll make it even more bulletproof :)

I suspect that there is one way of doing it…

Did I help you?
I manage this blog and share my knowledge for free, sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!





Layout items in flexible columns with Masonry

2 08 2014

In one of my projects I needed to layout photos in a grid that will place all photos most effectively with no white spaces between them. The prolem is that photos can have various sizes and proportions.

The Masonry is a javascript library, easy to use that layouts items in columns. Here is how my site looks after applying Masonry:

masonryDemo

In this case I used Masonry with:

– imagesLoaded to have callback when all images are loaded on a page

Unveil to lazy load images when they become visible on page

So sometimes it is a bit tricky, and its drawbacks may be observed – sometimes Masonry unfortunately does not layout items well. But it is quite hard to replicate, so I can recommend Masonry.








%d bloggers like this: