In a php file i have used include to include the following js.php file
and prior to that i have included the jquery file.
Yes, i noticed that sometimes is problem with that, i wrote safe solution for that, which fix this problem.
// jquery plugin 'jquery.ready.fix.js'
// @author Szymon Działowski
;(function ($) {
$.fn.ready.old || $(function (r) {
r = $.fn.ready;
$.fn.ready = function (fn) { $.isReady ? fn() : r(fn); };
$.fn.ready.old = r;
});
})(jQuery);
after that you can run code:
$(function () {alert('go')})
and it always fire alert.
PS: it is a technique called "duck punching" more about: http://www.paulirish.com/2010/duck-punching-with-jquery/