Title: Remove jQuery dependency
Last modified: August 30, 2016

---

# Remove jQuery dependency

 *  Resolved [Guti](https://wordpress.org/support/users/gutibitacorascom/)
 * (@gutibitacorascom)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/)
 * Anti spam plugin, is the lightest antibot spam plugin I have found. Not only 
   works fine, but also is light and fast.
 * To that regard, is a bit contradictory, to make it depend on jQuery, since according
   to what I saw, it is only used in js/anti-spam-3.5.js to perform some simple 
   DOM manipulations.
 * I do not know if you are interested in removing the dependecy, but if so, I can
   volunteer myself for converting it from jQuery to raw document.XXX functions.
 * Regards.
 * [https://wordpress.org/plugins/anti-spam/](https://wordpress.org/plugins/anti-spam/)

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/remove-jquery-dependency/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/remove-jquery-dependency/page/2/?output_format=md)

 *  [webvitalii](https://wordpress.org/support/users/webvitaly/)
 * (@webvitaly)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/#post-6523420)
 * **Wow. It would be awesome to re-write the plugin in pure javascript.**
 * I totally agree that jQuery is overkill in this case but I haven’t enough time
   to re-write code without it.
 * Are you planning to re-write it and send me an updated version of the plugin?
 * Or do you want me to create a git repo for it?
 * P.S. By the way Barca is my favorite football club 🙂
 *  Thread Starter [Guti](https://wordpress.org/support/users/gutibitacorascom/)
 * (@gutibitacorascom)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/#post-6523426)
 * Nice. I have performed a quick conversion, that I am now testing on my site.
 * In the meantime, you can get it at: [http://www.javiergutierrezchamorro.com/_temp/anti-spam-3.5.js.zip](http://www.javiergutierrezchamorro.com/_temp/anti-spam-3.5.js.zip)
 * Would be very nice if you can do a code review to it in the meantime.
 * Regards.
 *  Thread Starter [Guti](https://wordpress.org/support/users/gutibitacorascom/)
 * (@gutibitacorascom)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/#post-6523434)
 * I have been running the plugin with my Javascript conversion, and during 4 hours,
   it detected about 25 spam comments, so I guess modifications are working properly.
 * Also, I tested it using user comments with Opera, Internet Explorer, and Chrome
   and they were posted fine.
 * Then I tried with Lynx (without Javascript), and manually entering the year, 
   worked too.
 * So I guess, my code is OK. If it is fine to you, I would suggest releasing a 
   public beta, so we can asure it will work in different blog configurations. Makes
   sense?
 * Força Barça!
 *  [webvitalii](https://wordpress.org/support/users/webvitaly/)
 * (@webvitaly)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/#post-6523503)
 * Wow. You are quick.
    Your code looks great for me. I will give it a try on my
   websites for a week or two. During the next week I will do a public beta as you
   suggest for everyone to review and try before release the next major version.
 * Thank you very much for your contribution.
    This will speed up thousands of websites!
 * P.S. [Barca’s Tiki-Taka is the best teamplay skills ever](https://www.youtube.com/watch?v=lGuaQ1khn2k)!
   
   Star-team and not team of stars 🙂
 *  Thread Starter [Guti](https://wordpress.org/support/users/gutibitacorascom/)
 * (@gutibitacorascom)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/#post-6523506)
 * That’s good.
 * I could expect some minor glitches after the conversion, so let me know, and 
   I will take care of them.
 * Regards.
 *  Thread Starter [Guti](https://wordpress.org/support/users/gutibitacorascom/)
 * (@gutibitacorascom)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/#post-6523550)
 * I have updated the JS with some minor tweaks. Find it on same URL:
    [http://www.javiergutierrezchamorro.com/_temp/anti-spam-3.5.js.zip](http://www.javiergutierrezchamorro.com/_temp/anti-spam-3.5.js.zip)
 *  Thread Starter [Guti](https://wordpress.org/support/users/gutibitacorascom/)
 * (@gutibitacorascom)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/#post-6523569)
 * Hi [@webvitaly](https://wordpress.org/support/users/webvitaly/),
 * How is it going with your testing? Was everything OK?
 * Regards.
 *  [webvitalii](https://wordpress.org/support/users/webvitaly/)
 * (@webvitaly)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/#post-6523571)
 * Hi [@gutibitacorascom](https://wordpress.org/support/users/gutibitacorascom/),
 * I have couple issues/questions I cannot solve by myself.
    Do you have any ideas
   about them?
 * 1) When I am not hiding control with class “.antispam-control-q” – the value 
   inside of it is still the plugin’s version and not the year. But when I try to
   submit it – I got the “year” value. I think jQuery was able to change the value
   of the input during viewing it.
    Try to comment line and visit page with comment
   form without being logged in: `aElements[iElement].style.display = 'none';`
 * 2) When I am trying t submit post data I got “antspm-q” value twice.
    I think
   that the issue comes with adding extra dynamic_control via javascript.
 *     ```
       author:test
       email:test@test.com
       url:
       comment:comment test
       submit:Post Comment
       comment_post_ID:2
       comment_parent:0
       antspm-a:2015
       antspm-q:4.0
       antspm-e-email-url-website:
       antspm-q:2015
       ```
   
 * I reproduced these issues on Win7, Chrome 45, WordPress 4.3.1 and Twenty Fifteen
   theme.
 *  [webvitalii](https://wordpress.org/support/users/webvitaly/)
 * (@webvitaly)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/#post-6523572)
 * Hey [@gutibitacorascom](https://wordpress.org/support/users/gutibitacorascom/),
 * I made a 4.0.beta version.
    You may [download Anti-Spam version 4.0.beta from this page](http://web-profile.com.ua/wordpress/plugins/anti-spam/).
 * All inputs are visible for debug purposes.
 * The main **issue is that the value of the input with class “.antispam-control-
   q” is not changed** and form is submitting with the incorrect answer.
    It is 
   very strange because the Chrome debug tools shows the correct updated answer.
 * The form was working for you because you ware overriding this value with dynamically
   added input (dynamic_control) and this is why there are two values with the same
   name.
 * I changed the name of the dynamic_control input for not overlapping these two
   inputs.
 * P.S. I also update some code parts for the sake of readability.
    I know that 
   your code works a little bit faster, but IMHO in this case there are not too 
   many DOM manipulations and probably micro-optimizations does not worth it.
 *  Thread Starter [Guti](https://wordpress.org/support/users/gutibitacorascom/)
 * (@gutibitacorascom)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/#post-6523573)
 * Thanks for the testing and the beta.
 * I think that the problem is on the initialization, being called before the whole
   document is loaded. To that extent, I guess that removing the initialization 
   control and allowing it to initialize more than one time, will be the workarround:
 * if (anti_spam_initialized)
    { return; }
 * I think that the problem are on different events launched for initialization,
   they are there because DOMContentLoaded is not supported in all browsers, but
   in that case when DOMContentLoaded is supported, onload has already fired.
 * Will take a look at some events improvements to just initialize once.
 * Looking at your updated code, I would suggest precalculating items lenght before
   the loop, just to avoid counting the lenght of the elements on each iteration.
 *  Thread Starter [Guti](https://wordpress.org/support/users/gutibitacorascom/)
 * (@gutibitacorascom)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/#post-6523574)
 * Maybe we can use only DOMContentLoaded since most browsers already support it:
   
   [http://caniuse.com/#feat=domcontentloaded](http://caniuse.com/#feat=domcontentloaded)
 * What do you think about this simplification?
 *  [webvitalii](https://wordpress.org/support/users/webvitaly/)
 * (@webvitaly)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/#post-6523575)
 * Probably we can use only DOMContentLoaded if it will drop only IE8 support.
    
   Can we still maintain ajax requests and add changes to form after comments form
   was loaded via ajax?
 * I googled about length and .length will touch DOM after each iteration.
    Yeah,
   I agree now, it is better to precalculate length before every loop.
 * Can you update the beta version with your changes for DOMContentLoaded and share
   your updated version?
    Because I could make some mistakes there because of lack
   of javascript experience 🙂
 *  Thread Starter [Guti](https://wordpress.org/support/users/gutibitacorascom/)
 * (@gutibitacorascom)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/#post-6523577)
 * I replaced initialization event by only DOMContentLoaded, which simplifies code
   a lot, since it is only firing once (no need to check if already was initialized).
 * This fixed also the year textfield not filling properly according to my tests.
 * Also moved the length out of the loop scopes in order to increase performance.
 * As for the ajaxSuccess replacement, there is not a raw pure Javascript substitute.
   In fact this ajax event, is only taking care of AJAX requests managed by jquery,
   so if a plugin does an ajax request, it will not be captured. So not very reliable
   IMHO.
 * Take a look at the updated version at [http://www.javiergutierrezchamorro.com/_temp/anti-spam-4.0.js.zip](http://www.javiergutierrezchamorro.com/_temp/anti-spam-4.0.js.zip)
   and let me know if any concerns.
 * Cheers.
 *  [webvitalii](https://wordpress.org/support/users/webvitaly/)
 * (@webvitaly)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/#post-6523580)
 * Thank you very much for your help.
 * Your code updates looks good for me.
    I will test it for a few days and let you
   know if any updates will comes up.
 * All the best.
 *  Thread Starter [Guti](https://wordpress.org/support/users/gutibitacorascom/)
 * (@gutibitacorascom)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/#post-6523582)
 * Nice.
    Let me know if you notice any other problem.

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/remove-jquery-dependency/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/remove-jquery-dependency/page/2/?output_format=md)

The topic ‘Remove jQuery dependency’ is closed to new replies.

 * ![](https://ps.w.org/anti-spam/assets/icon-256x256.gif?rev=3469595)
 * [Titan Anti-spam & Security – Brute Force Protection, 2FA & Spam Filter](https://wordpress.org/plugins/anti-spam/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/anti-spam/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/anti-spam/)
 * [Active Topics](https://wordpress.org/support/plugin/anti-spam/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/anti-spam/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/anti-spam/reviews/)

## Tags

 * [dependency](https://wordpress.org/support/topic-tag/dependency/)
 * [dom](https://wordpress.org/support/topic-tag/dom/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)

 * 21 replies
 * 3 participants
 * Last reply from: [Guti](https://wordpress.org/support/users/gutibitacorascom/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/remove-jquery-dependency/page/2/#post-6523596)
 * Status: resolved