I want to use dd belatedpng so the PNG’s on my website appear properly on IE. The script I’ve always used on non-wordpress websites was

<!--[if lt IE 7 ]>
    <script src="https://wordpress.stackexchange.com/questions/6582/js/dd_belatedpng.js"></script>
    <script> DD_belatedPNG.fix('img, .ir'); </script>
<![endif]-->

Now that I need to use it on a WordPress website, I’m trying to find a way of adding script using enqueue script, although I don’t like it at all. At the end of the day, the theme is only going to be used on a single website, I’d prefer to hardcode the scripts path.

Anyway, is there a way of adding IE conditionals to enqueue script and or register script?

5 Answers
5

WordPress has a $is_IE global variable:

global $is_IE;
if($is_IE) enqueue_script(...);

Personally I prefer the IE conditional comments. Other browsers ignore them anyway, so there’s no reason to use PHP for browser detection.

You might also want to consider using 8 bit alpha PNG images instead of 24 bit PNGs, which don’t need any javascript fix in IE, and in most cases they will look the same as a 24 bit PNG.

Leave a Reply

Your email address will not be published. Required fields are marked *