So it never fails; I get a website up and running perfectly on Firefox and IE only to find that it is broken in Safari. After playing with the CSS for a while I’ve found that there isn’t much I can do. It has to do with some absolute(ly) positioned divisions and the background not stretching to fit. Im probably going to make another CSS file specifically for Safari machines, seeing as how Safari bugs have bit me at the worst times (like in an interview). I’ve been messing with JavaScript all night long and finally found a very easy way to detect Safari here:

http://dithered.chadlindstrom.ca/javascript/browser_detect/index.html

The specific browser type is combined with other browser information in the .userAgent variable, so you have to write some script to search through it. Its easier than it sounds. Here is the code:

var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('safari/') != -1){
alert("You're using Safari, moron!")
}

Told ya! Substitute ’safari’ for whatever you need to identify.

Edit - This script searches through the user agent string.  Visit this site to find strings for the browser you are trying to identify.

So you have your site running on the latest and greatest Java libraries, but your supporting CSS and JavaScript files are really starting to slow things down. You’re no JavaScript expert, so what do you do? Lucky for us some other people have already encountered this problem and have a great solution.

Make your pages load faster by combining and compressing javascript and css files

The site itself describes in great detail how the script works. It took some trial and error for me to get this thing working, so here are some tips:

  • If your site’s root folder is in another directory on your server, make sure you create an .htaccess file in that directory. There may be an .htaccess file in your public_html folder already, but unless that is your site’s root folder, you should not change it. Once you edit and place this file in your site’s root, all CSS and Java files accessed in their respective directories will be redirected to the combine.php script.
  • With the .htaccess file in mind, you need to place your combine.php file in the same directory, or edit your .htaccess file to point to combine.php.
  • Combine.php will compact and compress your files and send them to a cache folder that you need to create, again, in your site’s root directory. This way the client’s browser will access the cached files and wont request new files needlessly.
  • Once you have everything in place, you need to call your files in a way that the combine.php script recognizes. Here’s an example:
    <script type="text/javascript" src="combine.php?type=javascript&files=prototype.js,effects.js,lightWindow.js"></script>

If everything went as planned, you will use less bandwidth, your site may load a bit faster and your visitors will never know.

Learning how to write code can be tough. I was first introduced to AJAX (asynchronous JavaScript and XML) when building a website for a friend and artist. I learned to love Web design but found most employers want the full package; half artist, half logical programmer. So I set out to learn JavaScript and its uses. Anyway to wet your palate, I have included a few links that got me interested in learning JavaScript.

MiniAjax.com (careful, this loads a bit slow)
MooTools
Prototype (doesn’t play with MooTools; see moo.fx)
Lightbox

If you are a Web standards kind of person, you’ll know what I mean when I say AJAX is leaps ahead of Flash. I am still reluctant to learn action script for this reason, but that will depend on my future employer’s preferences (a whole other can of worms). When AJAX is implemented properly, client computers can have JavaScript completely disabled but they will still load all the content that the gracious Web developer hath provided them; they will only forfeit smooth Java-powered navigation. Try that with Flash.

So here I am trying to make myself more marketable by learning how to code JavaScript and PHP for the sake of creating my own AJAX apps. Lucky for us, there is a lot of information online and in local bookstores. I have compiled a small list of reading for people like me who do not come with a computer science degree. I’ll try to keep most of it online, but for your sake I suggest you go to a bookstore, grab some java coffee (ok, that was lame) and a Java/AJAX book. There should be plenty. I like to use a notepad and rewrite anything I’ll need to know. It saves money and it’s a great way to learn.

W3C Schools
AjaxLessons.com
Rasmus’ 30 second AJAX Tutorial
AJAX for Dummies (See also Java and XML for Dummies)

Ok, that’s all for now. I will continue to post what I find in hopes that someone out there will learn with me. We’re in this together.