---
title: "Launching jQuery plugins depending on the user location"  
description: "Launching jQuery plugins depending on the user location"  
author: "Anonymous User"  
published: 2013-05-15  
updated: 2013-05-15  
canonical: https://www.mindstick.com/forum/886/launching-jquery-plugins-depending-on-the-user-location  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# Launching jQuery plugins depending on the user location

Hi Guys!\
My senior gave me a task to put all little [javascript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript) and jQuery [plugin](https://www.mindstick.com/articles/23236/institute-management-for-wordpress-plugin) code in one file which will [execute](https://www.mindstick.com/interview/49/how-can-i-execute-a-php-script-using-command-line) these [plugins](https://www.mindstick.com/articles/65049/5-wordpress-plugins-to-help-you-amplify-your-seo-efforts), depending if the page has certain .classes or #ids. I am [thinking](https://www.mindstick.com/blog/11889/how-to-change-your-thinking-paradigm) what is the best way to do that.\
Will [simple](https://yourviews.mindstick.com/story/1469/5-simple-ways-to-stay-fit-amp-healthy) if -> else do in this case or should I go further and create something with .each?\
I also think that with the [growing](https://www.mindstick.com/articles/13068/mobile-apps-and-its-growing-importance-for-today-s-businesses) amount of plugins and other client-[side code](https://www.mindstick.com/forum/143/close-popup-window-by-server-side-code), there will be significant [performance issues](https://www.mindstick.com/forum/160277/how-execution-plan-can-help-identify-query-performance-issues). But so far we only have about 5-10 self-invoking functions.\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)! \

## Replies

### Reply by AVADHESH PATEL

Hi Ankita!\
How about something like this? It depends on how many elements it's going to have to cycle through. You could be more specific with span's, or div's if need be.\
var a_i = 0, b_i = 0;\
$("#ids").each(function() { a_i++;});\
$(".classes").each(function() { b_i++;});\
if(a_i != 0) { $.getScript("js/specific.plugin.min.js"); $.executePluginFunctionNameThingyHere();}\
if(b_i != 0) { $.getScript("js/another-specific.plugin.min.js"); $.executeOtherPluginFunctionNameThingyHere();}\
Not tested - but it's the general idea.


---

Original Source: https://www.mindstick.com/forum/886/launching-jquery-plugins-depending-on-the-user-location

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
