sega — 2012-12-10T16:32:27-05:00 — #1
Hi there guys,
I am currently looking into making my websites lighting fast and I wanted to list ways in which we can do this.
Minifying CSS and HTML
Reducing HTTP requests
Content Delivery Network
Avoiding empty image alt tags
Use CSS Sprites where possible
Are there any other ways we can speed up our websites.
PS: One of my websites has thousands of CSS declarations, are there any ways you can speed up your declarations?
felgall — 2012-12-10T16:35:21-05:00 — #2
ralphm — 2012-12-10T21:22:36-05:00 — #3
frontop — 2012-12-10T23:04:04-05:00 — #4
Choosing good and stable web space is also very important.
seanuk — 2012-12-11T14:15:04-05:00 — #5
Single line CSS, and all CSS in one file
same with JS, all into one file, and put the JS file at the bottom of your html file
sega — 2012-12-11T16:34:11-05:00 — #6
Are there any ways you can do this concentration of file locally? It's not on an online environment. Also are there any ways to safely minify your script without it breaking. From experience when you minify your JS it ends up breaking.
kohoutek — 2012-12-11T16:51:09-05:00 — #7
In addition to what you and others have listed, I'd also take the backend into account. It's equally important in terms performance. Whatever language, web framework or CMS you're using, there are always ways to improve performance and trim the fat. Some CMSes are hopelessly bloated, so your options are somewhat limited and dependent on the developers who created the CMS/Web Framework.
Still, there's quite a lot you can do, so I'd scan the web and look for bottlenecks and how to improve on them.
Same goes for databases, what kind of database you're using, whether or not you're applying extra layers. Depending on what you use, perhaps there are options to implement other ways to store your data.
I can recommend Steve Souders as the ultimate source in regards to performance: http://stevesouders.com/
His books are great, too, and I can wholeheartedly recommend them.
Well, you can group selectors and use as much shorthand code as possible. Thousands of declarations does sound quite a lot to me and I have the feeling you could reduce that a lot by approaching the markup differently, i.e. creating basic containers and styles and making those reusable.
In my mind, the best approach is a solid balance between scalability and performance.
ralphm — 2012-12-11T17:29:36-05:00 — #8
I'm not sure. But the alternative would be to put all your scripts into one file, I guess.
are there any ways to safely minify your script without it breaking. From experience when you minify your JS it ends up breaking.
I guess you could try different minifier tools to see which works best, such as this one:
endermb — 2012-12-12T07:19:00-05:00 — #9
It might be worth looking into YSlow if you want to reduce your page load times.
However, all of the suggestions raised are to do with front-end optimisation. In my experience it's definitely worth using a profiler on slow parts of your website to see if there are any issues with your code. For compiled frameworks like .NET this can help tremendously.
picnictutorials — 2012-12-12T08:06:24-05:00 — #10
In order on of speed results you'll likely see...
- optimize images (Photoshop > Menu > File > "save for web and devices" > usually best is between 40% - 60% optimization)
- put js scripts at bottom http://uxmovement.com/content/why-you-should-place-style-sheets-before-scripts/
- GZIP and compress files at server level http://www.visibilityinherit.com/code/yslow-&-google-page-speed-htaccess-code-how-to-speed-up-your-website.php
- combine css and js scripts into one file (one .css and one .js - keep the order originally on page)
- Compress js - dont worry about css http://compressorrater.thruhere.net/ (use YUI Compressor - prob the best and safest)
- sprites http://www.visibilityinherit.com/code/photoshop/sprite-navigation-image.php
kohoutek — 2012-12-12T08:50:36-05:00 — #11
I must be in invisible mode...
endermb — 2012-12-12T08:53:59-05:00 — #12
Ha! Apologies for missing your reply. I blame my missing glasses!
picnictutorials — 2012-12-12T08:58:53-05:00 — #13
I'm always in invisible mode. It's a setting I found deeply nested in My Sitepoint.
sega — 2012-12-12T20:23:53-05:00 — #14
Sorry for the late reply guys.
It's mainly due to the CSS switcher, it comprizes over 200 different backgrounds with over 8 variations styles and 7 different colors. To add to all that it's both responsive and retina-ready, so this did get a little bit complex. Normally I would not have so many declarations, but with everything said I hope it's understandable that this was not my choice. Typically I would end up with 50KB for the CSS, for this template it's over 100KB! So we need to fix this somehow.
I also found that when placing the external jQuery on the bottom of the page (just above the closing body) I get FOUC, something which I did not get before.
There are around 15 different script files. I used the minified version of them where possible. In addition to this I used head.js. I was recommended another tool by a friend - jQuery validation plug-in. I don't know how to use this and it's not something I feel will be straight-forward as it's purpose is validation and not minifying.
What I liked about head.js is that I could still keep the files in their natural state and it would run them in a single file one it's own. The only downside to this plug-in is that it does not minify the scripts. I could minify each CSS and JS individually which would probably save more space. A dream plug-in would be one that combines and minifies at the same time.
I have used spites a couple of time. This would be another cool way to speed up the website. Anything helps at this stage. Not entirely sure you'd do the CSS. Having spites would limit the http requests to files. Maybe another plug-in might be the solution here. CSSSpites are good, but from what I found you'd end up downloading a huge image you can do without. For instance, the template comprises of over 200 different backgrounds, some small other's big. A single CSS spite would limit the request but force a complete download.
The trouble is that there seams to be plug-ins for everything, and including all of these would further reduce the speed of your web page. A little like downloading a program to speed up your computer, which indoubtedly further slows your machine down.
For the images I use FastStone Resizer, which works wonders. It manages to reduce the file size of those images to something a little more acceptable. Maybe this combine with CSS Spites might further help the situation.
Because it's a template there will be no database. As far as I know the only thing I can do from the server side it to GZIP it and have it run on a CDN, something like CloudFlare. The CSS is as short as it could be, but maybe there is a little more I can do. Might also be worth using prefixfree, which would probably further reduce the file size of the overall CSS file.
I've used YSlow before. It's a great tool for isolated different issues. I will certainly use this tool. The only drawback I found with this is that it needs to be uploaded to a live environment to see it fully working.
Just wondering, would validation also play a role to the download speed of a web page. I tried to see what Facebook and Yahoo do, but they all have unvalidated web pages, and they seam to have some strange scripts going on there. Certainly not what I would call readable.
picnictutorials — 2012-12-12T20:45:24-05:00 — #15
"I also found that when placing the external jQuery on the bottom of the page (just above the closing body) I get FOUC, something which I did not get before."
system — 2012-12-13T03:02:20-05:00 — #16
you can use the css and js to make the code more clean and short. You can code it manual. For the small image like button you can use it spirit technology as background. have a good luck.
puneetjvw — 2012-12-15T07:20:08-05:00 — #17
If you are running a wordpress blog then install w3 cache plugin.
biztech — 2013-03-03T23:50:54-05:00 — #18
These are the easy steps to be followed, when developing a website to create it run faster. Here are some of them….
2. Put your CSS at the top of the document.
4. Use divide domain for images, javasripts etc...
5. Avoid URL Redirections
6. Use Image Sprites to Minimize HTTP Requests
7. Add an Expires or a Cache-Control
8. Use Gzip Components
9. Compress your images using Smushit or good image compressor.
johnnychen — 2013-03-04T02:23:49-05:00 — #19
If you are using Wordpress you can install some very useful plugins like W3 Total Cache
picnictutorials — 2013-03-04T21:46:31-05:00 — #20
Go here http://compressorrater.thruhere.net/ and use the YUI compression and you will never have any problems.
next page →