Is jQuery Making Us Forget About JavaScript?

The prevalence of jQuery on websites is massive. It is strange to not see some form of jQuery or other library on a website. I do have one question for web developers out there, are we forgetting how to use vanilla JavaScript in the process of letting jQuery take its place? This is not to say that we have forgotten how to code JavaScript, but rather that when we could have used pure JavaScript, we instead used jQuery.

Recently, I took on the task of removing jQuery from my own website and replacing it with vanilla JavaScript. Can’t be that hard right? It wasn’t quite as easy as I thought. This helped me realize that maybe I have become a little too comfortable with letting jQuery do everything for me, even when I may not have needed it. For a modern site that doesn’t have to provide legacy browser support, using pure JavaScript is actually less of a task than you would think. There are plenty of native functions that are very similar to functions in jQuery. If you are looking to support legacy browsers, then using jQuery makes sense because it makes cross-browser support a breeze (AJAX requests anyone?). 

Continue reading

Image Sprites VS Web Icon Fonts

There are a bunch of ways to increase the performance of your website. Many today are using image sprites and/or icon fonts. They help add a visual flair to your website, but also help decrease load times. This is all great, but you shouldn’t just jump into using either of these solutions without first knowing what their advantages and disadvantages are.

Image Sprites

Google's image sprite

Google’s image sprite

Continue reading

Speed Up Your Mobile Website

Performance is important on all sites, but on a mobile device, it is even more important. They have slower connections and less processing power than your computer or laptop. This already means a longer wait to see and interact with the content of a website. To further my point on web performance, check out this article on how it could affect your bottom line. Below I go through a few methods to speed up your mobile site and cut off some time from loading. Before you go ahead with any of these methods, check out your current page load time at pingdom.

Just note that these methods are not all specific to mobile, but can be used for your full website as well as the mobile version. Continue reading

Responsive Image Slider with jQuery and CSS Part 2

Check out Part 1 to see how I created the slider without a jQuery plugin.

In the first part we created a responsive image slider with jQuery and CSS. Now we will take that image slider and create a jQuery plugin out of it. I will cover the basics of making the plugin, but if you want to get a deeper background, head to the Plugins/Authoring section of the jQuery.com site. The plugin will do basically the same thing as the previous tutorial, but it will allow you to have more reusable code that is easier to extend. There is also the nice feature of passing in options that are easily changeable for users.

You can view the updated version of this slider here or download the source code. One extra feature to mention of the plugin is that you can now hover over it and it will pause on the current slide. This will stop the slider from transitioning when a user may want to interact with it.

Continue reading

Responsive Image Slider with jQuery and CSS Part 1

Edit: This is now a two part series. The first covers creating a slider with jQuery and the second creates the slider with a jQuery plugin. Check out Part 2.

Creating an image slider with jQuery can be quite challenging to newcomers, but it can help develop new skills that you can use elsewhere. There are a number of reasons to create your own slider and not rely on a third party script. Some sliders come with a lot of overhead and have a lot of unneeded code that you will never use. Creating your own can also give you a sense of accomplishment that you would never get using a third party slider script. I will take you through a step by step guide on how to create your own simple responsive slider. This will be a very lightweight slider that has minimal code.

Check out the demo before heading into the code. Download the source code.

Continue reading

Five Helpful JavaScript Resources

JavaScript frameworks and libraries are becoming better and more abundant with the introduction of HTML5 and CSS3 a few years ago. There are so many to choose from that it is hard to keep track of the good ones. Below I am going to go through a few that have stuck out to me as being amazingly helpful in development. These libraries can significantly cut development time by taking repetitive tasks and making them easy. Some can be learned in a few hours, while others will take a few days to learn. But in the long run, you will thank yourself for using these.

Continue reading

Five Ways to Secure Your PHP Application

With the huge growth of the internet, hacking has become a real problem.  While PHP is a powerful language, it has a few security vulnerabilities that hackers like to expose. This can be avoided by using different methods to make sure every hole is covered in your application. A lot of simple things can be done to avoid being hacked, but sometimes it is hard to catch them all. Be especially aware when using third-party plugins or scripts, as they may introduce security vulnerabilities that you may not know about. A good way to avoid that is to have the latest versions of those scripts.

Let’s get right into the list of 5 ways to secure your PHP application.

1. Escaping Input

This is a given and if you aren’t knowledgeable about this, now is the time to start. Even though this is simple, I believe it is worth revisiting for any programmer. mysql_real_escape_string() should be used any time you’re using variables from the user to query a MySQL database. Hackers can easily add an apostrophe and semi-colon to input (which would leave all preceding MySQL code as a comment) on the client side, which then gets ran on the server-side. One apostrophe and then a drop table could reap havoc on your database.

Here is a quick example.

Continue reading

Check A String For Unwanted Words With PHP

Most of us have come across a time when we have to clean up user input, or at least check if isn’t appropriate.  It is always nice to have a few functions that you can reuse on future projects. Recently, I have used the one below quite a bit, so I thought I would share.

This is a nice snippet of PHP code that will help you check for unwanted words contained in a string.

This function works by looping through each of the provided words and using the strpos() function to check if an unwanted word is contained within. The strpos() PHP function returns either the position of the string (if found) or a boolean value of false if not found. More information can be found on the php.net site. If a string contains any of the words that you have specified, it will return false.  This can come in handy when you want to make sure people are on their best behavior. Below is a quick example of how to put it to use.

If you have any questions, feel free to leave them below.

Converting String URLs to Clickable Links with Javascript

Recently I came across a problem, I needed to convert a plain text string, that could possibly have a URL in it, to a string with clickable URLs. This is possible with the right JavaScript code.  You could always do this on the server-side with PHP or another language, but I didn’t want to throw more text into my database.  So I searched and pieced together some code to take a plain text string and covert it to a clickable link with JavaScript. I created a simple function that takes a parameter of a string and searches for a valid URL (with a regular expression) within it.

script.js

All you have to do is call this function with a string as the parameter and it will return the new string with links.  If you wanted to search for more links, it would be as easy as creating another regular expression and parsing through the text again before returning it.

Here is the code you could use to call this function:

Here is a more complex case were http:// is left out:

There are of course the cases where someone could put a sub domain, this would not be caught be these regular expressions.

I hope this helped, if you have any questions or comments feel free to leave them below.

Button Class For Pure ActionScript Projects

When working in any language it pays to have a few classes that you can use in multiple projects.  I cannot count the number of times I have searched the interwebs for a well made button class in ActionScript 3, but sometimes you just have to make it yourself.  If you are looking for a button class for your next project I will be happy to share my class with you and show you how to use it.

There are quite a few advantages to have your classes built in pure ActionScript.  The size of our projects is ultimately what lead my team to switch Mad Components and the pure ActionScript approach.  You can take a project built-in Flash Builder and MXML from 6MB to 600KB without even breaking a sweat (maybe a mental sweat).  To save you more lecturing on the merits of the pure AS approach, I will get on to my UIButton class.

It is quite simple to implement the button:

UIButton

Simple button class

Continue reading