[EHPweb] jQuery and lib.js
Eric M Martinez
emartinez at usgs.gov
Tue Mar 8 15:03:15 UTC 2011
Hi Scott,
I'm not sure this is best. I don't know if you moved jQuery as well,
but that definitely needs to be in the head. Also, if anyone is using
the "addEvent" method (formerly in lib.js) to attach methods to the
window.load (per best practices), those are likely to fail as well.
Finally, the latest from Google suggests the analytics (asynchronous
snippet) should be in-line in the head as well. Maybe we would do
better to do something like:
head.inc.php:
-----------------------------------------------------------------
...
include_once 'master.js.php';
</head>
-----------------------------------------------------------------
master.js.php:
-----------------------------------------------------------------
<script type="text/javascript" src="jQuery-1.5.0.js"/>
<script type="text/javascript" src="master.js"/>
// Other HEAD section scripts
// ... maybe cat/pack all HEAD scripts into a single script (including
jQuery)
<script type="text/javascript">/**<![CDATA[*/
// In-line script for Google Analytics
/**]]>*/</script>
-----------------------------------------------------------------
master.js:
-----------------------------------------------------------------
// contents of lib.js + searchbox js + other template scripts
-----------------------------------------------------------------
Reference:
http://www.google.com/support/googleanalytics/bin/answer.py?answer=174090
Thanks,
~Eric.
On Mar 7, 2011, at 3:17 PM, Scott Haefner wrote:
> Hi web devs,
>
> On both ehpdevel and ehpstage:
>
> 1. I updated jQuery to 1.5.1. We have been running jQuery 1.5 on
> ehpdevel for several weeks now.
> 2. I removed lib.js from the <head> and added its functions to a new
> file called master.js that's included in the foot section.
>
> If your apps use jQuery and/or functions like hasClass or addEvent
> from lib.js, you should check to be sure they still work properly.
> Because the functions from lib.js are now included at the bottom of
> the page, inline javascripts relying on these functions will break.
> If you're following "best practices" (and not including javascript
> inline) these changes will not likely affect you.
>
> We will push these changes to earthquake on Wednesday, Mar 9.
>
> Scott
> _______________________________________________
> EHPweb mailing list
> EHPweb at geohazards.usgs.gov
> https://geohazards.usgs.gov/mailman/listinfo/ehpweb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://geohazards.usgs.gov/pipermail/ehpweb/attachments/20110308/17d5be20/attachment.html>
More information about the EHPweb
mailing list