This question already has answers here:
How can I reduce jQuery?
(7 answers)
Closed 1 year ago.
Is there a way to reduce jQuery to functions that I need.
In this case, I only want to use getJSON with the callback function. I don't need anything else of jQuery. Is there any way to cut this out?
Thanks,
Mike
You can do AJAX without jQuery. One explanation:
http://davekb.com/browse_programming_tips:easy_ajax:txt
Not really, there are a lot of dependencies, but modularity is planned.
As an aside, a getJSON() function isn't particularly hard to implement.
Related
This question already has answers here:
What does this regex mean
(4 answers)
Closed 12 months ago.
After searching for 'working onload event' I found Abhishek's anwser which used /in/ and after that, I tried searching for it but couldn't find anything useful about it, does someone know what does it do?
Without more context, /in/ looks like a regular expression (as mentioned by VLAZ), which you can learn more about here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
I also like https://regex101.com/ for help reading or writing complex regular expressions. Just make sure to select the Javascript "flavor" as different languages implement regular expressions differently.
This question already has answers here:
Maximum conditions inside if in javascript
(3 answers)
Closed 2 years ago.
Is there a limit to how many conditions (e.g., logical OR conditions) that JavaScript allows me to have in an if statement, or can I have as many as I want?
If technically have not limits, but If you want a clean code, I recommend you use switch case.
Know more about how to write better conditionals statements here: https://www.digitalocean.com/community/posts/5-tips-to-write-better-conditionals-in-javascript
You can have as many as you want 🙂
There is no limit to use as many as conditions you want , but if we have so many conditions its always good practice to use SWITCH case to make code clean and efficent.
This question already has answers here:
What are alternatives to document.write?
(11 answers)
Closed 3 years ago.
So guys, I made a little script to put in Tampermonkey for my presentations, but I have a problem.
What I want is to swap document.write(), but I don't know which function I could swap to replace it so that it leaves the code cleaner and more organized.
Besides document.write() is also not considered a good programming practice.
You could try to come up with your own function. But before taking any action, you need to think that there must be a injection into document body. You can try to use
document.body.appendChild()
and inside off that method, you can have some kind of html code.
Other than that you must generate a html document by using document.createDocumentFragment() or document.createElements().
This question already has answers here:
What is the difference between JavaScript and jQuery? [closed]
(6 answers)
Closed 7 years ago.
I have 1 year of experience in ui devoloper and i have to sweech my compony,
SO when i attened 1st interview the interviewer ask me one question i.e.
In your application you use javascript or Jquery or both,so i am not give him a proper answer so please anyone give me the answer for this question.
Pure javascript also known as vanilla js (like a joke). And pure js works faster than frameworks based on js.
There is a compartment of frameworks and pure js http://vanilla-js.com/. But using frameworks is easier than pure js.
This question already has answers here:
Lightweight alternative to jQuery for class / id selecting
(6 answers)
Closed 8 years ago.
I have this jQuery selector:
$('#stuffElements').find('[data-markerlayer="layer1"]');
I have a ton of selectors similar to this one, and I want to optimize my script as much as possible, as rewriting most selectors requires only minimal effort on my part.
Disregarding the discussion whether this is useful, is it possible to write the above selector out in pure JavaScript?
document.querySelectorAll('#stuffElements [data-markerlayer="layer1"]')
or to make it more efficient:
var holder = document.getElementById('#stuffElements'); // cache parent node
holder.querySelectorAll('[data-markerlayer="layer1"]'); // finds inside it
querySelectorAll doesn't work in IE7 if that bothers you.