Skip to main content
Participating Frequently
June 10, 2010
Question

Loading all of the Ajax library for one function?

  • June 10, 2010
  • 2 replies
  • 613 views

I have a login script on the front page of my website that uses some of CF9's ajax functionality. However, firebug is showing me that the cfm page is preloading the entire Ext JS library.

Is there a way to avoid this??

    This topic has been closed for replies.

    2 replies

    Inspiring
    June 11, 2010

    I tend to stay away from CF tags that generate js stuff.  They are great to show off how quick you can make draggable windows and ajax calls, but other than that they are pretty heavy and not too configurable.

    Although I agree that JS libraries (especially ext) can be bloated, I would recommend using jQuery.  Its light, easy to use and very modularized so you can load only the bits you want.  To go beyond that, I'd use google's CDN (content delivery network) to load the library.  That way, the strain isn't on your server, and chances are that your user will already have it cached in their browser because they visited another site that loaded it for them via google.

    Rolling your own ajax is great, and one should probably do that at least once.  But there's something to be said for projects like jQuery that have tested various systems/browsers and regularly enhance and maintain the code.

    ilssac
    Inspiring
    June 10, 2010

    Don't use a JavaScript Library.

    That is a common critique of a library.  While they can sometimes be a very handy addition, often they are a wrecking ball versus mosquito solution.  It is surely going to get the job done, but boy are you swinging a lot of weight around!

    A roll your own AJAX function using the xmlHTTPrequest() method is really not that difficult.  I really like the W3C Schools walk through.

    http://www.w3schools.com/XML/xml_http.asp

    Participating Frequently
    June 10, 2010

    I was actually trying to figure out why my page was retrieving that library. It looks like it has something to do with the cffwindow tag. When I removed that tag the page no longer retrieved that ~700kb ext-all.js file.

    ilssac
    Inspiring
    June 10, 2010

    Yes <cfwindow...> <cfdiv...> and other features are just ColdFusion tags that abstract more advance web application user interfaces using AJAX and DHTML functionality.