Loading ...
Sorry, an error occurred while loading the content.

Re: var $ = YAHOO.util.Dom.get;

Expand Messages
  • Edwart Visser
    It works for reducing the filesize, but it lacks readability. Also it can get in conflict with other JS libraries which depend on $ sign usage (i.e.
    Message 1 of 2 , Mar 3, 2008
    • 0 Attachment
      It works for reducing the filesize, but it lacks readability. Also it can get in conflict with other JS libraries which depend on $ sign usage (i.e. prototype). YAHOO is using their namespace to overcome this problem. With the "hack" you use this could stop working.

      A better approach would be creating shortcuts inside a namespace like this:

      YAHOO.namespace("somenamespace");

      YAHOO.somenamespace.myFunction = {
         init : function() {
            var Dom : YAHOO.util.Dom;
         }
      }

      // you can now call Dom.get(), inside the namespace.


      This is a bit more code than the $ approach, but it is more readable and it is not going to run into conflicts with other scripts.

      Regards,

      Edwart Visser
      www.lutsr.nl

      --- In ydn-javascript@yahoogroups.com, "mikeni1225" <mikeni1225@...> wrote:
      >
      > i have been replacing all yahoo.util.dom.get with $,  what is
      > everyone's thoughts on this?  i literally can reduce my file sizes by
      > kbs just by doing this.
      >

      --- In ydn-javascript@yahoogroups.com, "mikeni1225" <mikeni1225@...> wrote:
      >
      > i have been replacing all yahoo.util.dom.get with $, what is
      > everyone's thoughts on this? i literally can reduce my file sizes by
      > kbs just by doing this.
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.