not true, the javascript detects on the first lines if its the right browser
No, it’s true. The plugin loads the script everywhere.
From selectivizr/selectivizr.php:
// init
function rw_selectivizr() {
wp_enqueue_script('selectivizr',plugins_url( '/js/selectivizr.js' , __FILE__ ), array(), '1.0.b3' );
}
// load
add_action('wp_head', 'rw_selectivizr');
The script is what detects the browser.
From selectivizr/js/selectivizr.js:
(function(win) {
// Determine IE version and stop execution if browser isn't IE. This
// handles the script being loaded by non IE browsers because the
// developer didn't use conditional comments.
var ieUserAgent = navigator.userAgent.match(/MSIE (\d+)/);
if (!ieUserAgent) {
return false;
}
I think @m Designs means that the script shouldn’t even be loaded unless it’s needed. I agree. Why load yet another script if it’s not needed, even if it does die right away? Perhaps using global $is_IE along with a condition in the php file would be the solution…
I used the Original javascript as provided
https://github.com/keithclark/selectivizr
Looks nice, but it’s too much for me. I like this plugin 🙂
This is what I did in selectivizr.php:
function rw_selectivizr() {
global $is_IE;
if ($is_IE) {
wp_enqueue_script('selectivizr',plugins_url( '/js/selectivizr.js' , __FILE__ ), array(), '1.0.b3' );
}
}
Can you update the plugin with this code (or similar), please?
I`m working on a new version of this plugin on GitHub
https://github.com/Ramoonus/Powerpack
I will not edit the current version
I also found a more neat approach to the is_IE