Skip to content

SCOBot removal of jQuery dependency (Audit) for Version 4.0.0

Mark Statkus edited this page Jul 28, 2014 · 11 revisions

Recently, it came to my attention there are other popular frameworks being made. A side effect of adopting paradigms or working on large scale products is most often it will not always be jQuery.

jQuery is a great go-to library for solving cross-browser issues, traversing the DOM, but often if we're forcing someone to adopt jQuery in a project they already had a framework in, just to use SCOBot, we should pull out the dependency if its reasonable. Doing the math below, it seemed feasible.

You also may just be finally looking under the hood and or curious as to what this framework you've used for the past few years is even doing. You may even be surprised by it. You may not even realize the symptoms the framework is solving, because you didn't even know you had the problem to begin with.

SCOBot made use of the following jQuery functionality which in some respects has proven API's that had to hold up to the test of time, and generous contributions by the open source community.

  • $.extend
    • $.isFunction
  • $().triggerHandler
  • $().on
  • $.isPlainObject
    • $.isWindow
  • $.type
    • class2type
  • $.isArray
  • $().bind
  • $(obj)

Doesn't appear like much, but it actually was quite a bit. After a rough estimate, it came out around 150 lines of code that SCOBot was directly relying on. If you were to actually trim out comments and such it wasn't really all that much.

###Event System ... Then came listening and triggering events, and they are fired on / from JavaScript objects. Native JavaScript does not allow you to do this, you can only 'listen' to DOM Elements. Researched several examples of this online, and not withstanding browser compatibilty located an implemenation that seemed to asist with a rather low foot print.

Total size of the code after you minify/pack was 3.9KB vs having the larger JQuery library at 95KB.

##Tested:

###Mac OS X 10.9.4

  • Safari 7.0.5 OK
  • FireFox 30.0 OK
  • Chrome 36.0.1985.125 OK

###Windows XP

  • IE 8.0.6001.18702 OK
  • Chrome 35.0.1916.153 m OK
  • FireFox 20.0.1 OK

###Windows 7

  • IE 8 OK
  • IE 9 Untested
  • Chrome 36.0.1985.125 m OK
  • FireFox 31 OK

###Windows 8.1

  • IE 11.0.9600.16663 OK
  • Chrome 35.0.1916.114 m OK
  • FireFox 31.0 OK

Please open an issue if you encounter something not currently tested for. Whether we like it or not, we still have institutions using old software (maybe on new hardware) and we have to roll with the punches. The code base attempts to incorporate much of the best practices and approaches to solving the support for the above.