Support » Plugin: HeadJS Loader » [Plugin: HeadJS Loader] Scripts don't execute in order

  • Zach Waldowski

    (@zwaldowski)


    A syntax error in HeadJS’ Loader will indeed cause the scripts to load in parallel, but they will not execute in order as per HeadJS’ design. This can lead to, for example, a script loading before jQuery does and all hell breaking loose. This might be browser dependent (I didn’t test), but I was able to fix it by modifying the script to use HeadJS’ syntax, like so:

    if (!empty($script_array)) {
    		$script_array = array_unique($script_array);
    		$i=0;
    		foreach ($script_array as $script_location) {
    			/* Load the scripts into a .js */
    			if ($i != 0) { $js_files .= "\n    "; }
    			$js_files .= '"' . $script_location . '"';
    			if ($i + 1 != count($script_array)) { $js_files .= ","; }
    			$i++;
    		}
    		$headJS .= "\n<script>\nhead.js(" . $js_files . ");\n</script>";
    	}

    This may also be a side effect of me upgrading to the latest HeadJS (0.9). But that needs to be done at some point, also. XD

    http://wordpress.org/extend/plugins/headjs-loader/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: HeadJS Loader] Scripts don't execute in order’ is closed to new replies.