JavaScript functions in footer

Posted by Djave on Stack Overflow See other posts from Stack Overflow or by Djave
Published on 2012-06-06T10:34:26Z Indexed on 2012/06/06 10:40 UTC
Read the original article Hit count: 310

Filed under:
|
|

I'm currently using html5 boilerplate, which puts jQuery and your plugins into the footer. The only problem is, I use the same footer.php file in every page. How do I go about including page specific functions if the plugins aren't loaded yet? I.e.

<?php include_layout_template('header.php', '../');?>
<div id='mediaspace'>This text will be replaced</div>

<!-- Video for this page: -->

<script type='text/javascript'>
  jwplayer('mediaspace').setup({
  'flashplayer': '../resources/player.swf',
  'file': 'http://content.longtailvideo.com/videos/flvplayer.flv',
  'controlbar': 'bottom',
  'width': '470',
  'height': '320'
});
</script>

<?php //This file has the jwplayer function in it: 
include_layout_template('footer.php', '../'); ?>

Doing this I get

Uncaught ReferenceError: jwplayer is not defined 

Is it going to be easier to just put the plugin includes in the header? How do people usually tackle stuff like this in boilerplate/loading scripts at the end?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about load