Using native JavaScript instead of jQuery


« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Thomas Olesen on 19th September 2015
Hi

I tested RGraph, but since I use mootools I try to avoid to include jQuery too (- allthough it is possible to have both).

I believe jQuery may be necessary for some parts of the implementation, but it would be nice, if it was avoided when the task can easily be accomplished without.

eg. see attached patch for RGraph.common.core.js


regards Thomas

*** RGraph.common.core.js.org 2015-09-19 20:21:49.866525360 +0200
--- RGraph.common.core.js 2015-09-19 20:23:22.388070923 +0200
***************
*** 4389,4400 ****
  
               RG.cache[id] = {};
               RG.cache[id].object = obj;
               RG.cache[id].canvas = jQuery('<canvas></canvas>').attr({
                   width: obj.canvas.width,
                   height: obj.canvas.height,
                   id: 'background_cached_canvas' + obj.canvas.id
               })
! .get(0);
              
               //Add MSIE support
               if (typeof G_vmlCanvasManager === 'object' && G_vmlCanvasManager.initElement) {
--- 4389,4408 ----
  
               RG.cache[id] = {};
               RG.cache[id].object = obj;
+ /* TSO: Removed jquery dependency
               RG.cache[id].canvas = jQuery('<canvas></canvas>').attr({
                   width: obj.canvas.width,
                   height: obj.canvas.height,
                   id: 'background_cached_canvas' + obj.canvas.id
               })
! */
!
! /* TSO: substitute for jQuery done natively */
! RG.cache[id].canvas = document.createElement('canvas');
! RG.cache[id].canvas.setAttribute('width', obj.canvas.width);
! RG.cache[id].canvas.setAttribute('height', obj.canvas.height);
! RG.cache[id].canvas.setAttribute('id', 'background_cached_canvas' + obj.canvas.id);
!
              
               //Add MSIE support
               if (typeof G_vmlCanvasManager === 'object' && G_vmlCanvasManager.initElement) {
***************
*** 4531,4534 ****
       window.$cl = function (v)
       {
           return console.log(v);
! };
\ No newline at end of file
--- 4539,4542 ----
       window.$cl = function (v)
       {
           return console.log(v);
! };
Posted by Richard on 19th September 2015
Hi,

I have to admit - RGraph requiring jQuery is laziness on my part. I could easily take it out as you've shown - it's really not used much.

Some of the CSS effects use it for the .animate() function and the entry that you've shown here - but I don't (now) think that it's enough to warrant a dependency.

So I'll remove it. Thanks for the prod.



Richard
If RGraph has helped you - please share the website and give your feedback - thanks! You can give your feedback or leave a testimonial by adding a forum post

Add a reply

 




« Back to message list
RGraph on social media