分类: 系统运维
2009-04-23 12:08:44
When using the "Save for Web" tool in Photoshop, we can compress our images in order to lower their respective file sizes. But, did you know that the compression can be taken even further without sacrificing quality? A site named makes the process a cinch.
The team at Smush.It use a variety of tools.
* The list items above were taken from the .
So, just before deploying a new website, run your url through their service to reduce all of your images - thus speeding up your website. Beware - the service may convert your GIF files to PNG. You might need to update your HTML and CSS files accordingly. While we're on the subject, 99% of the time, saving as a PNG is the better decision. Unless you're using a tacky animated GIF, consider the PNG format to be best practice.
Many IDEs offer a "code snippet" panel that will allow you to save code for later use. Do you find yourself visiting lipsum.com too often to grab the generic text? Why not just save it as a snippet? In Dreamweaver, press "Shift F9" to open the snippet tab. You can then drag the appropriate snippet into the appropriate location. This features saves me SO much time over the course of a week.
You've downloaded the jQuery library, and you're slowly trying to grasp the syntax. Along the way, you hit a snag and realize that you can't figure out what the value of $someVariable is equal to. Easy, just do...
console.log($someVariable);
Now, load up Firefox - make sure you have installed - and press F12. You'll be presented with the correct value.
Now - multiply this by infinity and take it to the depths of forever and you still won't realize how useful Firebug and console.log() can be. :)
Created by , this unbelievably helpful Firefox plugin presents you with a plethora of options. Many of you who watch my screencasts know that I'm a fan of using the "Edit CSS" option to adjust my styles in real-time. Other helpful options include...
This is a procedure that we all don't perform enough. Though not always feasible, you can many times speed up your website by placing your script tags next to the closing
tag.....
Most current browsers can download a maximum of two components in parallel for each host name. However, when downloading a script, no other downloads can occur. That download must finish before moving forward.
So, when feasible, it makes perfect sense to move these files to the bottom of your document in order to allow the other components (images, css, etc) to load first.
If perfomance is paramount for your website, I strongly suggest that you consider compressing your CSS and Javascript files just before deployment. Don't bother doing it at the beginning of your development. It'll only cause more frustration than help. However, once the bow has been tied, compress those babies up.
Two other helpful tools for packing JavaScript code are YUI Compressor, and .
Additionally, you have the option of compressing your HTML - though I wouldn't recommend it. The file reduction is negligible.
Not too long ago, Jon Hobbs-Smith from tvidesign.co.uk posted a fantastic article that details 25 jQuery tips. Be sure to bookmark this page! Here are several of my favorites.
if ($('#myDiv).length) { // this code will only run if the div with an id of #myDiv exists. }
Many people don't realize that, when accessing dom elements, the jQuery function accepts a second parameter - "context". Consider the following...
var myElement = $('#someElement');
This code will require jQuery to traverse the entire DOM. We can improve the speed by using a context as the second parameter.
var myElement = $('#someElement', $('.someContainer'));
Now we're telling jQuery to only search within the .someContainer element, and to ignore everything outside of it.
When accessing IDs with jQuery, the library uses the traditional "getElementById" method. However, when accessing classes, jQuery must use its own methods to traverse the dom (there isn't a native "getElementByClass" method). As a result, it takes a bit longer!
If you have the choice between $_GET or $_POST when making AJAX calls, choose the former.
"The Yahoo! Mail team found that when using XMLHttpRequest, POST is implemented in the browsers as a two-step process: sending the headers first, then sending data. So it's best to use GET, which only takes one TCP packet to send (unless you have a lot of cookies)." - Developer.Yahoo.com
Remember - don't blindly use $_GET. Make sure you know exactly what you're doing first. For example, under no circumstances should you mix the querystring and database access. Not too long ago, one of my buddies sent me an image of a live website containing a MYSQL query in the url. DON'T DO THIS! :)
Whether you're using PHP, ASP.NET, Mootools, jQuery - or a combination of all of them, consider using frameworks when appropriate.
For example:
However, if I'm building a complicated site that requires a full CMS and complicated data access, I'll take a look at one of my preferred language's frameworks.
Remember - make frameworks work for you; not the other way around. Be smart when making these decisions.
YSlow is a wonderful service that checks your website to ensure that it's as efficient as possible. The Yahoo Dev team, not too long ago, created a set of guidelines, or best practices, that should be followed when developing - many of which are detailed in this article, actually.
There's a great YSlow screencast that demonstrates many time saving techiques. I highly recommend that you view it when you have the chance.
Most experienced designers/developers will agree with me; if I had to go up to the toolbar menu every time I wanted to make a change to my site or design, I'd be lost. I've been using keyboard shortcuts for so long that I don't know the correct location anymore for these commands. I just know that "Shift X" opens the correct panel.
At first, it can seem like wasted knowledge. But, I assure you that it isn't. I recommend that you do a Google search for "X keyboard shortcuts" - where X is equal to your software (i.e. Photoshop). Print the chart out and place it next to your computer. Over the next few weeks, practice touching your mouse as little as possible. This is one thing that separates the pros from the hobbyists.
Let's face it; not every website needs to be some huge and complicated application. Sometimes, we simply want to display our portfolio - probably most of the time for some! In these instances, why not create a simple "template" that contains everything you need to get started.
Within my template folder, I have nested "JS" and "CSS" folders.
In addition, I have an "index.html(php)" file that contains a few code snippets that I use on most of my projects. It's nothing too fancy, but it saves time!
Untitled Document