I am developing a webpage in PHP with Laravel. I want to use the attributes "defer" or "async" for my javascript files, but I have a few problems. In every document, I load a header which contains:
{{ Html::script('js/jquery.js', array('defer' => 'defer')) }}
{{ Html::script('js/bootstrap.min.js', array('defer' => 'defer')) }}
{{ Html::script('js/pjax.js', array('defer' => 'defer')) }}
{{ Html::script('js/jquery.cookie.js', array('defer' => 'defer')) }}
{{ Html::script('js/blur.js', array('defer' => 'defer')) }}
{{ Html::script('js/scrollbar.js', array('defer' => 'defer')) }}
<!--Form-->
{{ Html::script('js/parsley/parsley.remote.js', array('defer' => 'defer')) }}
{{ Html::script('js/parsley/parsley.js', array('defer' => 'defer')) }}
{{ Html::script('js/parsley/es.js', array('defer' => 'defer')) }}
{{ Html::script('js/icheck.js', array('defer' => 'defer')) }}
<!--Funciones-->
{{ Html::script('js/funciones.js', array('defer' => 'defer')) }}
If I give them the attribute async, the don't work properly because some of them are modular. So I've tried with the defer attribute and I don't have this problem, but now I have a problem with the inline javascript, because it calls a function of the header. (This is at the bottom of the page).
<script type="text/javascript">
window.addEventListener('popstate', function(e) {
eval(document.getElementById("script_biblioteca").innerHTML);
});
//Scripts on back/forward
section = 'biblioteca';
url_section = "{{Request::root()}}/"+section+"/";
activar_menu('#menu_biblioteca');
buscador('#dinamic_search', '#main', section);
</script>
And the error:
ReferenceError: $ is not defined
ReferenceError: activar_menu is not defined
How can I fix that? And, I am using the "defer" attribute properly?